Bug 1334283 - use MOZ_FORMAT_PRINTF in toolkit/mozapps/update; r?rstrong draft
authorTom Tromey <tom@tromey.com>
Tue, 02 May 2017 08:55:19 -0600
changeset 571935 fe805af540b86c4b74758d78b89bbadb5a32c42a
parent 571515 6daa1df9f158fc66aebb1727565b788db449753d
child 626922 0091a603e70d1a2ac5361f837bdcf8fb9b16b3da
push id56964
push userbmo:ttromey@mozilla.com
push dateWed, 03 May 2017 14:51:48 +0000
reviewersrstrong
bugs1334283
milestone55.0a1
Bug 1334283 - use MOZ_FORMAT_PRINTF in toolkit/mozapps/update; r?rstrong Use MOZ_FORMAT_PRINTF in toolkit/mozapps/update, and fix the one erroneous printf that this detected. MozReview-Commit-ID: 5dzyMOZwNDG
toolkit/mozapps/update/common/updatecommon.h
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/mozapps/update/common/updatecommon.h
+++ b/toolkit/mozapps/update/common/updatecommon.h
@@ -2,31 +2,32 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef UPDATECOMMON_H
 #define UPDATECOMMON_H
 
 #include "updatedefines.h"
 #include <stdio.h>
+#include "mozilla/Attributes.h"
 
 class UpdateLog
 {
 public:
   static UpdateLog & GetPrimaryLog() 
   {
     static UpdateLog primaryLog;
     return primaryLog;
   }
 
   void Init(NS_tchar* sourcePath, const NS_tchar* fileName);
   void Finish();
   void Flush();
-  void Printf(const char *fmt, ... );
-  void WarnPrintf(const char *fmt, ... );
+  void Printf(const char *fmt, ... ) MOZ_FORMAT_PRINTF(2, 3);
+  void WarnPrintf(const char *fmt, ... ) MOZ_FORMAT_PRINTF(2, 3);
 
   ~UpdateLog()
   {
     Finish();
   }
 
 protected:
   UpdateLog();
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -435,17 +435,17 @@ get_relative_path(const NS_tchar *fullpa
  *         Whether the path is a directory path. Defaults to false.
  * @return valid filesystem path or nullptr if the path checks fail.
  */
 static NS_tchar*
 get_valid_path(NS_tchar **line, bool isdir = false)
 {
   NS_tchar *path = mstrtok(kQuote, line);
   if (!path) {
-    LOG(("get_valid_path: unable to determine path: " LOG_S, line));
+    LOG(("get_valid_path: unable to determine path: " LOG_S, *line));
     return nullptr;
   }
 
   // All paths must be relative from the current working directory
   if (path[0] == NS_T('/')) {
     LOG(("get_valid_path: path must be relative: " LOG_S, path));
     return nullptr;
   }