Ro5bert / avra

Assembler for the Atmel AVR microcontroller family
GNU General Public License v2.0
153 stars 39 forks source link

warnings from GCC 12 in macro.c #50

Open sharkcz opened 2 years ago

sharkcz commented 2 years ago

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.