Skip to content

Conversation

@ggdavisiv
Copy link

Fix a couple of build warnings.

George G. Davis added 2 commits June 13, 2025 21:37
Fix the following build warnings:

$ aarch64-linux-gnu-gcc devmem2.c
devmem2.c: In function ‘main’:
devmem2.c:120:66: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  120 |         sprintf(fmt_str, "Read at address  0x%%08lX (%%p): 0x%%0%dlX\n", 2*data_size);
      |                                                                 ~^       ~~~~~~~~~~~
      |                                                                  |        |
      |                                                                  int      size_t {aka long unsigned int}
      |                                                                 %ld
devmem2.c:148:74: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  148 |                 sprintf(fmt_str, "Write at address 0x%%08lX (%%p): 0x%%0%dlX, "
      |                                                                         ~^
      |                                                                          |
      |                                                                          int
      |                                                                         %ld
  149 |                         "readback 0x%%0%dlX\n", 2*data_size, 2*data_size);
      |                                                 ~~~~~~~~~~~
      |                                                  |
      |                                                  size_t {aka long unsigned int}
devmem2.c:148:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  148 |                 sprintf(fmt_str, "Write at address 0x%%08lX (%%p): 0x%%0%dlX, "
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  149 |                         "readback 0x%%0%dlX\n", 2*data_size, 2*data_size);
      |                                                              ~~~~~~~~~~~
      |                                                               |
      |                                                               size_t {aka long unsigned int}
devmem2.c:149:41: note: format string is defined here
  149 |                         "readback 0x%%0%dlX\n", 2*data_size, 2*data_size);
      |                                        ~^
      |                                         |
      |                                         int
      |                                        %ld

Signed-off-by: George G. Davis <george.davis@teradyne.com>
Fix the following build warning:

$ aarch64-linux-gnu-gcc -Wunused-parameter devmem2.c
devmem2.c: In function ‘fixup_addr’:
devmem2.c:160:51: warning: unused parameter ‘size’ [-Wunused-parameter]
  160 | static inline void *fixup_addr(void *addr, size_t size)
      |                                            ~~~~~~~^~~~

Signed-off-by: George G. Davis <george.davis@teradyne.com>
@ggdavisiv ggdavisiv force-pushed the devmem2-fix-build-warnings branch from 063552e to fed8447 Compare June 14, 2025 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant