Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate some gcc warnings #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andy-bower
Copy link
Contributor

Eliminate some warnings found with gcc-13.2.

-Wformat

gcc -DLOCALEDIR=\"/usr/share/locale\" -DHAVE_CONFIG_H   -I/usr/include/i386-linux-gnu  -I/usr/include/libxml2   -Wdate-time -D_FORTIFY_SOURCE=2  -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/builds/abower/mcds/debian/output/source_dir=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -c -o mcds-mem.o 'test -f 'mem.c' || echo './''mem.c
In file included from gettext.h:26,
                 from mem.c:35:
mem.c: In function 'xmalloc':
mem.c:60:24: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
   60 |     errx(EX_SOFTWARE,_("out of memory (unable to allocate %ld bytes)"), n);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mem.c:60:22: note: in expansion of macro '_'
   60 |     errx(EX_SOFTWARE,_("out of memory (unable to allocate %ld bytes)"), n);
      |                      ^
mem.c:60:61: note: format string is defined here
   60 |     errx(EX_SOFTWARE,_("out of memory (unable to allocate %ld bytes)"), n);
      |                                                           ~~^
      |                                                             |
      |                                                             long int
      |                                                           %d

-Wunused-variable

gcc -DLOCALEDIR=\"/usr/share/locale\" -DHAVE_CONFIG_H   -I/usr/include/i386-linux-gnu  -I/usr/include/libxml2   -Wdate-time -D_FORTIFY_SOURCE=2  -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/builds/abower/mcds/debian/output/source_dir=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -c -o mcds-rc.o `test -f 'rc.c' || echo './'`rc.c
rc.c: In function 'read_rc':
rc.c:75:27: warning: unused variable 'nfile' [-Wunused-variable]
   75 |         static const char nfile[] = ".netrc";  /* Netrc file */
      |                           ^~~~~

-Wstringop-trunctation

rc.c:127:41: warning: '__builtin_strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
  127 |                                         strncpy(vals[i], tmp, len);
      |                                         ^
rc.c:122:39: note: length computed here
  122 |                                 len = strlen(tmp);
      |                                       ^~~~~~~~~~~

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