Skip to content

Commit

Permalink
build: Add -Wshadow
Browse files Browse the repository at this point in the history
samu.c: In function ‘main’:
samu.c:187:21: warning: declaration of ‘n’ shadows a previous local [-Wshadow]
  187 |                 int n = sysconf(_SC_NPROCESSORS_ONLN);
      |                     ^
samu.c:126:22: note: shadowed declaration is here
  126 |         struct node *n;
      |                      ^
  • Loading branch information
orbea authored and michaelforney committed Jun 17, 2023
1 parent c16d450 commit 88cb6f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
ALL_CFLAGS=$(CFLAGS) -std=c99 -Wall -Wextra -Wpedantic -Wno-unused-parameter
ALL_CFLAGS=$(CFLAGS) -std=c99 -Wall -Wextra -Wshadow -Wpedantic -Wno-unused-parameter
OBJ=\
build.o\
deps.o\
Expand Down
6 changes: 3 additions & 3 deletions samu.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,16 @@ main(int argc, char *argv[])
argdone:
if (!buildopts.maxjobs) {
#ifdef _SC_NPROCESSORS_ONLN
int n = sysconf(_SC_NPROCESSORS_ONLN);
switch (n) {
int nproc = sysconf(_SC_NPROCESSORS_ONLN);
switch (nproc) {
case -1: case 0: case 1:
buildopts.maxjobs = 2;
break;
case 2:
buildopts.maxjobs = 3;
break;
default:
buildopts.maxjobs = n + 2;
buildopts.maxjobs = nproc + 2;
break;
}
#else
Expand Down

0 comments on commit 88cb6f5

Please sign in to comment.