Skip to content

hulog.cpp/humalloc.cpp: Use inttypes - #24

Merged
d99kris merged 1 commit into
d99kris:dev/integrate-build-warning-fixesfrom
sebastianertz:inttypes
Jun 28, 2026
Merged

d99kris merged 1 commit into
d99kris:dev/integrate-build-warning-fixesfrom
sebastianertz:inttypes

Conversation

@sebastianertz

Copy link
Copy Markdown
Contributor

Prevent warnings on 386 architecture.

/root/a/src/hulog.cpp: In function ‘void log_event(int, void*, size_t)’:
/root/a/src/hulog.cpp:319:64: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  319 |                 fprintf(f, "%s Address %p is a block of size %ld free'd at:\n",
      |                                                              ~~^
      |                                                                |
      |                                                                long int
      |                                                              %d
  320 |                         hu_prefix, ptr, allocation->second.size);
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~ 
      |                                                            |
      |                                                            size_t {aka unsigned int}
/root/a/src/hulog.cpp: In function ‘void hu_sig_handler(int, siginfo_t*, void*)’:
/root/a/src/hulog.cpp:381:44: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  381 |             fprintf(f, "%s Address %p is %ld bytes after a block of size %ld alloc'd at:\n",
      |                                          ~~^
      |                                            |
      |                                            long int
      |                                          %d
  382 |                     hu_prefix, ptr, offset, allocation->second.size);
      |                                     ~~~~~~  
      |                                     |
      |                                     size_t {aka unsigned int}
/root/a/src/hulog.cpp:381:76: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  381 |             fprintf(f, "%s Address %p is %ld bytes after a block of size %ld alloc'd at:\n",
      |                                                                          ~~^
      |                                                                            |
      |                                                                            long int
      |                                                                          %d
  382 |                     hu_prefix, ptr, offset, allocation->second.size);
      |                                             ~~~~~~~~~~~~~~~~~~~~~~~         
      |                                                                |
      |                                                                size_t {aka unsigned int}
/root/a/src/hulog.cpp:400:46: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  400 |               fprintf(f, "%s Address %p is %ld bytes after a block of size %ld free'd at:\n",
      |                                            ~~^
      |                                              |
      |                                              long int
      |                                            %d
  401 |                       hu_prefix, ptr, offset, allocation->second.size);
      |                                       ~~~~~~  
      |                                       |
      |                                       size_t {aka unsigned int}
/root/a/src/hulog.cpp:400:78: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  400 |               fprintf(f, "%s Address %p is %ld bytes after a block of size %ld free'd at:\n",
      |                                                                            ~~^
      |                                                                              |
      |                                                                              long int
      |                                                                            %d
  401 |                       hu_prefix, ptr, offset, allocation->second.size);
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~         
      |                                                                  |
      |                                                                  size_t {aka unsigned int}
/root/a/src/hulog.cpp:416:46: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  416 |               fprintf(f, "%s Address %p is %ld bytes inside a block of size %ld free'd at:\n",
      |                                            ~~^
      |                                              |
      |                                              long int
      |                                            %d
  417 |                       hu_prefix, ptr, offset, allocation->second.size);
      |                                       ~~~~~~  
      |                                       |
      |                                       size_t {aka unsigned int}
/root/a/src/hulog.cpp:416:79: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  416 |               fprintf(f, "%s Address %p is %ld bytes inside a block of size %ld free'd at:\n",
      |                                                                             ~~^
      |                                                                               |
      |                                                                               long int
      |                                                                             %d
  417 |                       hu_prefix, ptr, offset, allocation->second.size);
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~          
      |                                                                  |
      |                                                                  size_t {aka unsigned int}
/root/a/src/humalloc.cpp: In function ‘int hu_mprotect(void*, size_t, int)’:
/root/a/src/humalloc.cpp:106:54: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
  106 |     fprintf(stderr, "heapusage error: mprotect(%p, %ld, %d) failed errno %d\n",
      |                                                    ~~^
      |                                                      |
      |                                                      long int
      |                                                    %d
  107 |             addr, len, prot, errno);
      |                   ~~~                                 
      |                   |
      |                   size_t {aka unsigned int}
/root/a/src/humalloc.cpp:120:32: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long unsigned int’ [-Wformat=]
  120 |               "max_map_count=%ld mprotect_count=%ld, try increasing max_map_count, ex:\n",
      |                              ~~^
      |                                |
      |                                long int
      |                              %lld
  121 |               max_map_count, callcount);
      |               ~~~~~~~~~~~~~     
      |               |
      |               long long unsigned int
/root/a/src/humalloc.cpp:120:51: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  120 |               "max_map_count=%ld mprotect_count=%ld, try increasing max_map_count, ex:\n",
      |                                                 ~~^
      |                                                   |
      |                                                   long int
      |                                                 %lld
  121 |               max_map_count, callcount);
      |                              ~~~~~~~~~             
      |                              |
      |                              uint64_t {aka long long unsigned int}
/root/a/src/humalloc.cpp:122:44: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long unsigned int’ [-Wformat=]
  122 |       fprintf(stderr, "sudo sh -c \"echo %ld > /proc/sys/vm/max_map_count\"\n",
      |                                          ~~^
      |                                            |
      |                                            long int
      |                                          %lld
  123 |               (2 * max_map_count));
      |               ~~~~~~~~~~~~~~~~~~~           
      |                  |
      |                  long long unsigned int

@d99kris d99kris self-assigned this Jun 27, 2026
@d99kris
d99kris changed the base branch from master to dev/integrate-build-warning-fixes June 28, 2026 05:35
@d99kris
d99kris merged commit b8ad143 into d99kris:dev/integrate-build-warning-fixes Jun 28, 2026
2 checks passed
@d99kris

d99kris commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Thanks for contributing @sebastianertz - the fix has been merged to heapusage master now.

@sebastianertz
sebastianertz deleted the inttypes branch June 28, 2026 06:26
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.

2 participants