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

warnings from GCC 12 in macro.c #50

Open
sharkcz opened this issue Jun 2, 2022 · 0 comments
Open

warnings from GCC 12 in macro.c #50

sharkcz opened this issue Jun 2, 2022 · 0 comments

Comments

@sharkcz
Copy link

sharkcz commented Jun 2, 2022

The better diagnostics in GCC 12 prints some new warnings when compiling macro.c, see bellow.

cc -Wall -O3 -DDEFAULT_INCLUDE_PATH='"/usr/local/include/avr"' -DVERSION='"1.4.2"'   -c -o macro.o macro.c
macro.c: In function ‘read_macro’:
macro.c:196:36: warning: the comparison will always evaluate as ‘true’ for the address of ‘buff’ will never be NULL [-Waddress]
  196 |                         } else if (pi->fi->buff && pi->list_file && pi->list_on) {
      |                                    ^~
In file included from macro.c:35:
avra.h:194:14: note: ‘buff’ declared here
  194 |         char buff[LINEBUFFER_LENGTH];
      |              ^~~~

Because pi->fi->buff is always non-NULL, the question is whether it should check for pi->fi->buff[i] instead ...

macro.c: In function ‘expand_macro’:
macro.c:502:33: warning: ‘strncat’ specified bound 1 equals source length [-Wstringop-overflow=]
  502 |                                 strncat(buff, "\n", 1);
      |                                 ^~~~~~~~~~~~~~~~~~~~~~

this is a case of wrong use of strncat(), please read for example https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83404#c1. Same applies to the next strncat() call.

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

No branches or pull requests

1 participant