1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix many compiler warnings and remove unused variables (#191)

Most of these changes remove unused variables, functions and labels
to fix -Wunused compiler warnings. Somewhat notable changes:

src/cmd/ksh93/bltins/print.c:
- Removed the unused 'neg' variable.
  Patch from ksh2020: https://github.com/att/ast/pull/725

src/cmd/ksh93/bltins/sleep.c:
- Initialized ns to fix three -Wsometimes-uninitialized warnings.

src/cmd/ksh93/edit/{emacs,vi}.c:
- Adjust strncpy size to fix two -Wstringop-truncation warnings.

src/cmd/ksh93/include/shell.h:
- The NOT_USED macro caused many -Wunused-value warnings,
  so it has been replaced with ksh2020's macro:
  19d0620a

src/cmd/ksh93/sh/expand.c:
- Removed an unnecessary 'ap = ' since 'ap' is never read
  between stakseek and stakfreeze.

src/cmd/ksh93/edit/vi.c: refresh():
- Undef this function's 'w' macro at the end of it to stop it
  potentially interfering with future code changes.

src/cmd/ksh93/sh/nvdisc.c,
src/lib/libast/misc/magic.c,
src/lib/libast/regex/regsubexec.c,
src/lib/libast/sfio/sfpool.c,
src/lib/libast/vmalloc/vmbest.c:
- Fixed some indentation to silence -Wmisleading-indentation
  warnings.

src/lib/libast/include/ast.h:
- For clang, now only suppress hundreds of -Wparentheses warnings
  as well as a few -Wstring-plus-int warnings.
  Clang's -Wparentheses warns about things like
  	if(foo = bar())
  which assigns to foo and checks the assigned value.
  Clang wants us to change this into
  	if((foo = bar()))
  Clang's -Wstring-plus-int warns about things like
  	"string"+x
  where x is an integer, e.g. "string"+3 represents the string
  "ing". Clang wants us to change that to
  	"string"[3]
  The original versions represent a perfectly valid coding style
  that was common in the 1980s and 1990s and is not going to change
  in this historic code base. (gcc does not complain about these.)

Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
Johnothan King 2021-02-22 14:16:32 -08:00 committed by GitHub
parent 83630f9d1c
commit 733f70e94b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 64 additions and 113 deletions

View file

@ -1344,7 +1344,7 @@ static void search(Emacs_t* ep,genchar *out,int direction)
#if SHOPT_MULTIBYTE
ed_external(string,(char*)string);
#endif /* SHOPT_MULTIBYTE */
strncpy(lstring,((char*)string)+2,SEARCHSIZE);
strncpy(lstring,((char*)string)+2,SEARCHSIZE-1);
lstring[SEARCHSIZE-1] = 0;
ep->prevdirection = direction;
}

View file

@ -67,12 +67,10 @@
# define iswprint(c) ((c&~0177) || isprint(c))
# endif
static int _isalph(int);
static int _ismetach(int);
static int _isblank(int);
# undef isblank
# define isblank(v) _isblank(virtual[v])
# define isalph(v) _isalph(virtual[v])
# define ismetach(v) _ismetach(virtual[v])
#else
static genchar _c;
# define gencpy(a,b) strcpy((char*)(a),(char*)(b))
@ -81,7 +79,6 @@
# define isalph(v) ((_c=virtual[v])=='_'||isalnum(_c))
# undef isblank
# define isblank(v) isspace(virtual[v])
# define ismetach(v) ismeta(virtual[v])
# define digit(c) isdigit(c)
# define is_print(c) isprint(c)
#endif /* SHOPT_MULTIBYTE */
@ -2098,6 +2095,7 @@ static void refresh(register Vi_t* vp, int mode)
cursor(vp,ncur_phys);
ed_flush(vp->ed);
return;
# undef w
}
/*{ REPLACE( char, increment )
@ -2323,7 +2321,7 @@ static int search(register Vi_t* vp,register int mode)
location = hist_find(shgd->hist_ptr,((char*)virtual)+1, curhline, 1, new_direction);
}
cur_virt = i;
strncpy(lsearch, ((char*)virtual)+1, SEARCHSIZE);
strncpy(lsearch, ((char*)virtual)+1, SEARCHSIZE-1);
lsearch[SEARCHSIZE-1] = 0;
if( (curhline=location.hist_command) >=0 )
{
@ -2785,12 +2783,6 @@ yankeol:
{
return((v&~STRIP)==0 && isspace(v));
}
static int _ismetach(register int v)
{
return((v&~STRIP)==0 && ismeta(v));
}
#endif /* SHOPT_MULTIBYTE */
/*