of defeating gcc's warn_unused_result attribute.
--HG--
branch : 1.7
# endif
#endif
+#ifdef __GNUC__
+# define ignore_result(x) do { \
+ __typeof__(x) y = (x); \
+ (void)y; \
+} while(0)
+#else
+# define ignore_result(x) (void)(x)
+#endif
+
/* GNU stow needs /etc/sudoers to be a symlink. */
#ifdef USE_STOW
# define stat_sudoers stat
# endif
#endif
+#ifdef __GNUC__
+# define ignore_result(x) do { \
+ __typeof__(x) y = (x); \
+ (void)y; \
+} while(0)
+#else
+# define ignore_result(x) (void)(x)
+#endif
+
/* GNU stow needs /etc/sudoers to be a symlink. */
#ifdef USE_STOW
# define stat_sudoers stat
* The pipe is non-blocking, if we overflow the kernel's pipe
* buffer we drop the signal. This is not a problem in practice.
*/
- if (write(signal_pipe[1], &signo, sizeof(signo)) == -1)
- /* shut up glibc */;
+ ignore_result(write(signal_pipe[1], &signo, sizeof(signo)));
}
#ifdef SA_SIGINFO
* The pipe is non-blocking, if we overflow the kernel's pipe
* buffer we drop the signal. This is not a problem in practice.
*/
- if (write(signal_pipe[1], &signo, sizeof(signo)) == -1)
- /* shut up glibc */;
+ ignore_result(write(signal_pipe[1], &signo, sizeof(signo)));
}
}
#endif /* SA_SIGINFO */
io_fds[SFD_USERTTY] : STDOUT_FILENO;
if (write(n, reason, strlen(reason)) != -1) {
if (WCOREDUMP(cstat->val)) {
- if (write(n, " (core dumped)", 14) == -1)
- /* shut up glibc */;
+ ignore_result(write(n, " (core dumped)", 14));
}
- if (write(n, "\n", 1) == -1)
- /* shut up glibc */;
+ ignore_result(write(n, "\n", 1));
}
}
}
exec_pty(path, argv, envp, rbac, &errpipe[1]);
cstat.type = CMD_ERRNO;
cstat.val = errno;
- if (write(errpipe[1], &cstat, sizeof(cstat)) == -1)
- /* shut up glibc */;
+ ignore_result(write(errpipe[1], &cstat, sizeof(cstat)));
_exit(1);
}
close(errpipe[1]);
#ifdef HAVE_ZLIB_H
if (def_compress_io)
- gzwrite(io_fds[idx].g, buf, len);
+ ignore_result(gzwrite(io_fds[idx].g, (const voidp)buf, len));
else
#endif
- fwrite(buf, 1, len, io_fds[idx].f);
+ ignore_result(fwrite(buf, 1, len, io_fds[idx].f));
delay.tv_sec = now.tv_sec;
delay.tv_usec = now.tv_usec;
timevalsub(&delay, &last_time);
}
continue;
}
- if (write(fd, "*", 1) == -1)
- /* shut up glibc */;
+ ignore_result(write(fd, "*", 1));
}
*cp++ = c;
}
static int continued, prev_state, sawspace;
+#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout))
+
static int _push_include __P((char *, int));
static int pop_include __P((void));
static char *parse_include __P((char *));
#define INSTR 5
-#line 1518 "lex.yy.c"
+#line 1520 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
register char *yy_cp, *yy_bp;
register int yy_act;
-#line 126 "toke.l"
+#line 128 "toke.l"
-#line 1674 "lex.yy.c"
+#line 1676 "lex.yy.c"
if ( yy_init )
{
case 1:
YY_RULE_SETUP
-#line 127 "toke.l"
+#line 129 "toke.l"
{
LEXTRACE(", ");
LEXRETURN(',');
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 132 "toke.l"
+#line 134 "toke.l"
BEGIN STARTDEFS;
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 134 "toke.l"
+#line 136 "toke.l"
{
BEGIN INDEFS;
LEXTRACE("DEFVAR ");
case 4:
YY_RULE_SETUP
-#line 143 "toke.l"
+#line 145 "toke.l"
{
BEGIN STARTDEFS;
LEXTRACE(", ");
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 149 "toke.l"
+#line 151 "toke.l"
{
LEXTRACE("= ");
LEXRETURN('=');
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 154 "toke.l"
+#line 156 "toke.l"
{
LEXTRACE("+= ");
LEXRETURN('+');
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 159 "toke.l"
+#line 161 "toke.l"
{
LEXTRACE("-= ");
LEXRETURN('-');
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 164 "toke.l"
+#line 166 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 171 "toke.l"
+#line 173 "toke.l"
{
LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng))
case 10:
YY_RULE_SETUP
-#line 180 "toke.l"
+#line 182 "toke.l"
{
/* Line continuation char followed by newline. */
sudolineno++;
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 186 "toke.l"
+#line 188 "toke.l"
{
LEXTRACE("ENDSTR ");
BEGIN prev_state;
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 218 "toke.l"
+#line 220 "toke.l"
{
LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng))
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 224 "toke.l"
+#line 226 "toke.l"
{
LEXTRACE("STRBODY ");
if (!append(yytext, yyleng))
case 14:
YY_RULE_SETUP
-#line 232 "toke.l"
+#line 234 "toke.l"
{
/* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 240 "toke.l"
+#line 242 "toke.l"
{
/* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 248 "toke.l"
+#line 250 "toke.l"
{
BEGIN INITIAL;
yyless(0);
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 254 "toke.l"
+#line 256 "toke.l"
{
LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace))
case 18:
YY_RULE_SETUP
-#line 262 "toke.l"
+#line 264 "toke.l"
{
char *path;
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 280 "toke.l"
+#line 282 "toke.l"
{
char *path;
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 301 "toke.l"
+#line 303 "toke.l"
{
char deftype;
int n;
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 341 "toke.l"
+#line 343 "toke.l"
{
int n;
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 367 "toke.l"
+#line 369 "toke.l"
{
/* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD ");
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 373 "toke.l"
+#line 375 "toke.l"
{
/* cmnd requires passwd for this user */
LEXTRACE("PASSWD ");
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 379 "toke.l"
+#line 381 "toke.l"
{
LEXTRACE("NOEXEC ");
LEXRETURN(NOEXEC);
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 384 "toke.l"
+#line 386 "toke.l"
{
LEXTRACE("EXEC ");
LEXRETURN(EXEC);
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 389 "toke.l"
+#line 391 "toke.l"
{
LEXTRACE("SETENV ");
LEXRETURN(SETENV);
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 394 "toke.l"
+#line 396 "toke.l"
{
LEXTRACE("NOSETENV ");
LEXRETURN(NOSETENV);
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 399 "toke.l"
+#line 401 "toke.l"
{
LEXTRACE("LOG_OUTPUT ");
LEXRETURN(LOG_OUTPUT);
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 404 "toke.l"
+#line 406 "toke.l"
{
LEXTRACE("NOLOG_OUTPUT ");
LEXRETURN(NOLOG_OUTPUT);
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 409 "toke.l"
+#line 411 "toke.l"
{
LEXTRACE("LOG_INPUT ");
LEXRETURN(LOG_INPUT);
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 414 "toke.l"
+#line 416 "toke.l"
{
LEXTRACE("NOLOG_INPUT ");
LEXRETURN(NOLOG_INPUT);
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 419 "toke.l"
+#line 421 "toke.l"
{
/* empty group or netgroup */
LEXTRACE("ERROR ");
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 425 "toke.l"
+#line 427 "toke.l"
{
/* netgroup */
if (!fill(yytext, yyleng))
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 433 "toke.l"
+#line 435 "toke.l"
{
/* group */
if (!fill(yytext, yyleng))
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 441 "toke.l"
+#line 443 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 448 "toke.l"
+#line 450 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 455 "toke.l"
+#line 457 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 466 "toke.l"
+#line 468 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 477 "toke.l"
+#line 479 "toke.l"
{
LEXTRACE("ALL ");
LEXRETURN(ALL);
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 483 "toke.l"
+#line 485 "toke.l"
{
#ifdef HAVE_SELINUX
LEXTRACE("ROLE ");
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 492 "toke.l"
+#line 494 "toke.l"
{
#ifdef HAVE_SELINUX
LEXTRACE("TYPE ");
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 501 "toke.l"
+#line 503 "toke.l"
{
#ifndef HAVE_SELINUX
got_alias:
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 511 "toke.l"
+#line 513 "toke.l"
{
/* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng))
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 519 "toke.l"
+#line 521 "toke.l"
{
BEGIN GOTCMND;
LEXTRACE("COMMAND ");
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 526 "toke.l"
+#line 528 "toke.l"
{
/* directories can't have args... */
if (yytext[yyleng - 1] == '/') {
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 541 "toke.l"
+#line 543 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 548 "toke.l"
+#line 550 "toke.l"
{
/* a word */
if (!fill(yytext, yyleng))
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 556 "toke.l"
+#line 558 "toke.l"
{
LEXTRACE("( ");
LEXRETURN('(');
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 561 "toke.l"
+#line 563 "toke.l"
{
LEXTRACE(") ");
LEXRETURN(')');
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 566 "toke.l"
+#line 568 "toke.l"
{
LEXTRACE(", ");
LEXRETURN(',');
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 571 "toke.l"
+#line 573 "toke.l"
{
LEXTRACE("= ");
LEXRETURN('=');
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 576 "toke.l"
+#line 578 "toke.l"
{
LEXTRACE(": ");
LEXRETURN(':');
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 581 "toke.l"
+#line 583 "toke.l"
{
if (yyleng & 1) {
LEXTRACE("!");
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 588 "toke.l"
+#line 590 "toke.l"
{
if (YY_START == INSTR) {
LEXTRACE("ERROR ");
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 600 "toke.l"
+#line 602 "toke.l"
{ /* throw away space/tabs */
sawspace = TRUE; /* but remember for fill_args */
}
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 604 "toke.l"
+#line 606 "toke.l"
{
sawspace = TRUE; /* remember for fill_args */
sudolineno++;
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 610 "toke.l"
+#line 612 "toke.l"
{
BEGIN INITIAL;
sudolineno++;
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 618 "toke.l"
+#line 620 "toke.l"
{
LEXTRACE("ERROR ");
LEXRETURN(ERROR);
case YY_STATE_EOF(STARTDEFS):
case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR):
-#line 623 "toke.l"
+#line 625 "toke.l"
{
if (YY_START != INITIAL) {
BEGIN INITIAL;
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 633 "toke.l"
+#line 635 "toke.l"
ECHO;
YY_BREAK
-#line 2450 "lex.yy.c"
+#line 2452 "lex.yy.c"
case YY_END_OF_BUFFER:
{
return 0;
}
#endif
-#line 633 "toke.l"
+#line 635 "toke.l"
struct path_list {
char *path;
static int continued, prev_state, sawspace;
+#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout))
+
static int _push_include __P((char *, int));
static int pop_include __P((void));
static char *parse_include __P((char *));
(void) unlink(sp->tpath);
if (!oldperms && fstat(sp->fd, &sb) != -1) {
if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID)
- (void) chown(sp->path, SUDOERS_UID, SUDOERS_GID);
+ ignore_result(chown(sp->path, SUDOERS_UID, SUDOERS_GID));
if ((sb.st_mode & 0777) != SUDOERS_MODE)
- (void) chmod(sp->path, SUDOERS_MODE);
+ ignore_result(chmod(sp->path, SUDOERS_MODE));
}
return TRUE;
}
{
cleanup(signo);
#define emsg " exiting due to signal.\n"
- if (write(STDERR_FILENO, getprogname(), strlen(getprogname())) == -1 ||
- write(STDERR_FILENO, emsg, sizeof(emsg) - 1) == -1)
- /* shut up glibc */;
+ ignore_result(write(STDERR_FILENO, getprogname(), strlen(getprogname())));
+ ignore_result(write(STDERR_FILENO, emsg, sizeof(emsg) - 1));
_exit(signo);
}