Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
changes to remove this gcc warning:
Browse files Browse the repository at this point in the history
  -- ignoring return value of [xxx], declared with attribute warn_unused_result
  • Loading branch information
ericmandel committed Mar 21, 2019
1 parent b2d7c54 commit 0e6f150
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
26 changes: 18 additions & 8 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,13 +1061,19 @@ static int XPAClientGet(xpa, client)
if( xpa->nclient > 1 ){
snprintf(tbuf, SZ_LINE, "XPA$BEGIN %s:%s %s\n",
client->xclass, client->name, client->method);
write(client->fd, tbuf, strlen(tbuf));
if( write(client->fd, tbuf, strlen(tbuf)) < 0 ){
fprintf(stderr, "warning: XPA client can't write header\n");
}
}
if( write(client->fd, *(client->bufptr), *(client->lenptr)) < 0 ){
fprintf(stderr, "warning: XPA client can't write data\n");
}
write(client->fd, *(client->bufptr), *(client->lenptr));
if( xpa->nclient > 1 ){
snprintf(tbuf, SZ_LINE, "XPA$END %s:%s %s\n",
client->xclass, client->name, client->method);
write(client->fd, tbuf, strlen(tbuf));
if( write(client->fd, tbuf, strlen(tbuf)) < 0 ){
fprintf(stderr, "warning: XPA client can't write header\n");
}
}
/* we can free buf, since its not being passed back */
if( *(client->bufptr) ){
Expand Down Expand Up @@ -1096,7 +1102,9 @@ static int XPAClientGet(xpa, client)
/* for single client fd mode, we write immediately -- this deals with
the important case of one client with a large amount of data */
if( (client->mode & XPA_CLIENT_FD) && (xpa->nclient == 1) ){
write(client->fd, *(client->bufptr), *(client->lenptr));
if( write(client->fd, *(client->bufptr), *(client->lenptr)) < 0 ){
fprintf(stderr, "warning: XPA client can't write data\n");
}
/* reset buf for next read */
if( *(client->bufptr) ) xfree(*(client->bufptr));
*(client->bufptr) = NULL;
Expand Down Expand Up @@ -1532,8 +1540,9 @@ static int XPAClientLoopFork(xpa, mode)
else if( pid == 0 ){ /* child */
/* child write to parent that he is active */
close(fd[0]);
write(fd[1], &active, 1);
close(fd[1]);
if( write(fd[1], &active, 1) >= 0 ){
close(fd[1]);
}
#ifdef USE_DOUBLE_FORK
/* second fork prevents zombies:
when child/parent exits, second child is inherited
Expand All @@ -1552,8 +1561,9 @@ static int XPAClientLoopFork(xpa, mode)
} else { /* parent */
/* parent waits for child to wake up */
close(fd[1]);
read(fd[0], &active, 1);
close(fd[0]);
if( read(fd[0], &active, 1) >= 0 ){
close(fd[0]);
}
#ifdef USE_DOUBLE_FORK
/* for double fork, also wait for intermediate process to exit */
waitpid(pid, NULL, 0);
Expand Down
4 changes: 3 additions & 1 deletion find.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ char *ResolvePath(ibuf, obuf, maxlen)

/* if we have a relative path to deal with, get current directory */
if( (*ibuf == '.') || ( (strchr(ibuf, '/') != NULL) && (*ibuf != '/') ) ){
getcwd(path, MAXBUFSIZE);
if( !getcwd(path, MAXBUFSIZE) ){
*path = '\0';
}
}
else{
*path = '\0';
Expand Down
4 changes: 3 additions & 1 deletion xalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ static void _xalloc_error(void)
static void _xalloc_error()
#endif
{
write(1, XALLOC_ERROR, strlen(XALLOC_ERROR));
if( write(1, XALLOC_ERROR, strlen(XALLOC_ERROR)) < 0 ){
exit(1);
}
#if XALLOC_SETJMP
if( xalloc_envptr )
longjmp(*xalloc_envptr, XALLOC_SETJMP);
Expand Down
9 changes: 6 additions & 3 deletions xlaunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ static int launch_fork_exec(char *cmdstring, int attach,
case 2:
/* if stderr is the same as stdout, just dup */
if( stdfiles[1] && !strcmp(stdfiles[1], stdfiles[i]) ){
dup(1);
if( dup(1) < 0 ){
_exit(-1);
}
}
else{
if( open(stdfiles[i], O_CREAT|O_WRONLY|O_TRUNC, 0600) < 0){
Expand Down Expand Up @@ -279,8 +281,9 @@ static int launch_fork_exec(char *cmdstring, int attach,
status = 127;
#if LAUNCH_USE_PIPE
if( !attach ){
write(fd[1], &status, 4);
close(fd[1]);
if( write(fd[1], &status, 4) >= 0 ){
close(fd[1]);
}
}
#endif
_exit(status); /* exec error */
Expand Down

0 comments on commit 0e6f150

Please sign in to comment.