]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- allow compiler to check format strings
authorArvin Schnell <aschnell@suse.de>
Thu, 22 Nov 2018 08:56:25 +0000 (09:56 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 22 Nov 2018 08:56:25 +0000 (09:56 +0100)
client/snapper.cc
client/utils/text.cc
client/utils/text.h
snapper/AppUtil.cc
snapper/AppUtil.h

index 46240068a819a762d40bd7cfa194e635b0b8b3ce..842bf6c9853f99e71bcb2aff3b9bb257d7ce998c 100644 (file)
@@ -807,7 +807,7 @@ help_delete()
 void
 filter_undeletables(ProxySnapshots& snapshots, vector<ProxySnapshots::iterator>& nums)
 {
-    auto filter = [&snapshots, &nums](ProxySnapshots::const_iterator undeletable, const string& message)
+    auto filter = [&snapshots, &nums](ProxySnapshots::const_iterator undeletable, const char* message)
     {
        if (undeletable == snapshots.end())
            return;
index e454110a0664208c33aeb89452b860f6c99986c5..8610071d77e77b52c5ecf761c5aab98508dc66ac 100644 (file)
 
 using namespace std;
 
-string _(const char* msgid)
+
+const char*
+_(const char* msgid)
 {
     return dgettext("snapper", msgid);
 }
 
-string _(const char* msgid, const char* msgid_plural, unsigned long int n)
+
+const char*
+_(const char* msgid, const char* msgid_plural, unsigned long int n)
 {
     return dngettext("snapper", msgid, msgid_plural, n);
 }
index d1f4d5737a56a956ea0d788b0596c35f45abeb1e..9e055f8b3a4a07d3a21b7cc2ff181554a03334b0 100644 (file)
 #include <string>
 #include <iosfwd>
 
-std::string _(const char* msgid);
-std::string _(const char* msgid, const char* msgid_plural, unsigned long int n);
+const char* _(const char* msgid) __attribute__ ((format_arg(1)));
+
+const char* _(const char* msgid, const char* msgid_plural, unsigned long int n)
+    __attribute__ ((format_arg(1))) __attribute__ ((format_arg(2)));
 
 /** Returns the column width of a multi-byte character string \a str */
 unsigned mbs_width (const std::string & str);
index 052235d5e63748bc32646613530324034199d853..1d8fb96729968567a142bbc6744ba8c59f0b3bdc 100644 (file)
@@ -237,14 +237,14 @@ namespace snapper
 
 
     string
-    sformat(const string& format, ...)
+    sformat(const char* format, ...)
     {
        char* result;
        string str;
 
        va_list ap;
        va_start(ap, format);
-       if (vasprintf(&result, format.c_str(), ap) != -1)
+       if (vasprintf(&result, format, ap) != -1)
        {
            str = result;
            free(result);
index d2211e7760fca76c2c0b0152672d35ed3719b5ad..75947a10ac19233c639e46d4fe0d576580aacce1 100644 (file)
@@ -111,7 +111,7 @@ namespace snapper
     };
 
 
-    string sformat(const string& format, ...);
+    string sformat(const char* format, ...) __attribute__ ((format(printf, 1, 2)));
 
 
     struct runtime_error_with_errno : public std::runtime_error