albsod / pinetime-hypnos

Zephyr firmware for the nRF52832 PineTime smartwatch
Apache License 2.0
73 stars 21 forks source link

[bug] Compilation warnings #74

Closed endian-albin closed 4 years ago

endian-albin commented 4 years ago

The default build command west build -p -b pinetime hypnos generates the warnings below. They don't show up when building with bootloader support disabled.

pinetime-hypnos/zephyr/include/logging/log_core.h:238:10: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
  238 |   printk("%c: " fmt "\n", z_log_minimal_level_to_char(_level), \
      |          ^~~~~~
pinetime-hypnos/zephyr/include/logging/log_core.h:266:5: note: in expansion of macro 'Z_LOG_TO_PRINTK'
  266 |     Z_LOG_TO_PRINTK(_level, __VA_ARGS__);        \
      |     ^~~~~~~~~~~~~~~
pinetime-hypnos/zephyr/include/logging/log_core.h:296:2: note: in expansion of macro '__LOG'
  296 |  __LOG(_level,           \
      |  ^~~~~
pinetime-hypnos/zephyr/include/logging/log.h:40:25: note: in expansion of macro 'Z_LOG'
   40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
      |                         ^~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:9: note: in expansion of macro 'LOG_ERR'
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |         ^~~~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:33: note: format string is defined here
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |                                ~^
      |                                 |
      |                                 unsigned int
      |                                %lx
In file included from pinetime-hypnos/zephyr/include/logging/log.h:11,
                 from pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:22:
pinetime-hypnos/zephyr/include/logging/log_core.h:155:24: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=]
  155 | #define Z_LOG_STR(...) "%s: " GET_ARG1(__VA_ARGS__), __func__\
      |                        ^~~~~~
pinetime-hypnos/zephyr/include/logging/log_core.h:188:30: note: in definition of macro '__LOG_INTERNAL'
  188 |    log_from_user(_src_level, __VA_ARGS__);   \
      |                              ^~~~~~~~~~~
pinetime-hypnos/zephyr/include/logging/log_core.h:279:14: note: in expansion of macro 'Z_LOG_STR'
  279 |              Z_LOG_STR(__VA_ARGS__));\
      |              ^~~~~~~~~
pinetime-hypnos/zephyr/include/logging/log_core.h:296:2: note: in expansion of macro '__LOG'
  296 |  __LOG(_level,           \
      |  ^~~~~
pinetime-hypnos/zephyr/include/logging/log.h:40:25: note: in expansion of macro 'Z_LOG'
   40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
      |                         ^~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:9: note: in expansion of macro 'LOG_ERR'
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |         ^~~~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:33: note: format string is defined here
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |                                ~^
      |                                 |
      |                                 unsigned int
      |                                %lx
In file included from pinetime-hypnos/zephyr/include/logging/log.h:11,
                 from pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:22:
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:17: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |                 ^~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                             |
      |                                                             long unsigned int
pinetime-hypnos/zephyr/include/logging/log_core.h:188:30: note: in definition of macro '__LOG_INTERNAL'
  188 |    log_from_user(_src_level, __VA_ARGS__);   \
      |                              ^~~~~~~~~~~
pinetime-hypnos/zephyr/include/logging/log_core.h:296:2: note: in expansion of macro '__LOG'
  296 |  __LOG(_level,           \
      |  ^~~~~
pinetime-hypnos/zephyr/include/logging/log.h:40:25: note: in expansion of macro 'Z_LOG'
   40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
      |                         ^~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:9: note: in expansion of macro 'LOG_ERR'
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |         ^~~~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:33: note: format string is defined here
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |                                ~^
      |                                 |
      |                                 unsigned int
      |                                %lx
In file included from pinetime-hypnos/zephyr/include/logging/log.h:11,
                 from pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:22:
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:17: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [-Wformat=]
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |                 ^~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                             |
      |                                                             long unsigned int
pinetime-hypnos/zephyr/include/logging/log_core.h:291:27: note: in definition of macro '__LOG'
  291 |    log_printf_arg_checker(__VA_ARGS__);         \
      |                           ^~~~~~~~~~~
pinetime-hypnos/zephyr/include/logging/log.h:40:25: note: in expansion of macro 'Z_LOG'
   40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
      |                         ^~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:9: note: in expansion of macro 'LOG_ERR'
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |         ^~~~~~~
pinetime-hypnos/modules/lib/mcumgr/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c:339:33: note: format string is defined here
  339 |         LOG_ERR("bad offset (0x%x)", fa->fa_off + num_bytes -1);
      |                                ~^
      |                                 |
      |                                 unsigned int
      |                                %lx
endian-albin commented 4 years ago

The warnings go away if we upgrade mcumgr to cfe5eb98a9493017448846fd1a44a9340bd0a22f and then change two lines:

@@ -49,7 +49,7 @@ fs_mgmt_impl_read(const char *path, size_t offset, size_t len,
     ssize_t bytes_read;
     int rc;

-    rc = fs_open(&file, path, FS_O_READ);
+    rc = fs_open(&file, path);
     if (rc != 0) {
         return MGMT_ERR_ENOENT;
     }
@@ -123,7 +123,7 @@ fs_mgmt_impl_write(const char *path, size_t offset, const void *data,
         }
     }

-    rc = fs_open(&file, path, FS_O_CREATE | FS_O_WRITE);
+    rc = fs_open(&file, path);
     if (rc != 0) {
         return MGMT_ERR_EUNKNOWN;
     }