Skip to content

Commit cb5978d

Browse files
committed
compiler warning: stringop-overflow
Adjust NCOPY macros to avoid stringop-overflow warning.
1 parent 62f0ea2 commit cb5978d

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

configure.ac

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,8 @@ DEBUGTOOL_LIBS=
764764
# -------------------------------------
765765
AC_DEFUN([AX_HANDLE_EXTRA_WARNING],
766766
[if test "x$enable_extra_warning" != xyes; then
767-
# Too many false positives.
768-
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
769-
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overflow],
770-
[$1="$$1 -Wno-stringop-overflow"],
771-
[],
772-
[-Werror])
767+
# Currently no warnings are disabled without --enable-extra-warning
768+
$1
773769
fi[]dnl
774770
])
775771

sources/declare.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@
6767
#define ParseSignedNumber(x,s) { int sgn; ParseSign(sgn,s)\
6868
ParseNumber(x,s) if ( sgn ) x = -x; }
6969

70-
#define NCOPY(s,t,n) while ( --n >= 0 ) *s++ = *t++;
71-
70+
/* (n) is necessary here, since the macro is sometimes passed dereferenced pointers for n */
71+
#define NCOPY(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
7272
/*#define NCOPY(s,t,n) { memcpy(s,t,n*sizeof(WORD)); s+=n; t+=n; n = -1; }*/
73-
#define NCOPYI(s,t,n) while ( --n >= 0 ) *s++ = *t++;
74-
#define NCOPYB(s,t,n) while ( --n >= 0 ) *s++ = *t++;
75-
#define NCOPYI32(s,t,n) while ( --n >= 0 ) *s++ = *t++;
76-
#define WCOPY(s,t,n) { int nn=n; WORD *ss=(WORD *)s, *tt=(WORD *)t; while ( --nn >= 0 ) *ss++=*tt++; }
73+
#define NCOPYI(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
74+
#define NCOPYB(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
75+
#define NCOPYI32(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
76+
#define WCOPY(s,t,n) { int nn=n; WORD *ss=(WORD *)s, *tt=(WORD *)t; while ( (nn)-- > 0 ) { *ss++ = *tt++; } }
77+
7778
#define NeedNumber(x,s,err) { int sgn = 1; \
7879
while ( *s == ' ' || *s == '\t' || *s == '-' || *s == '+' ) { \
7980
if ( *s == '-' ) {sgn = -sgn;} s++; } \

0 commit comments

Comments
 (0)