Changeset 0483e1e for unix.c


Ignore:
Timestamp:
2016-11-28T19:26:16Z (5 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
90254d0
Parents:
2a1c27f
Message:

Fix some compiler warnings

warn_unused_result on write() is particularly annoying. You can't just
add (void) to ignore it due to gcc bug 66425.

I replaced some of those with fwrite() and used a variable marked with
the G_GNUC_UNUSED attribute for the writes from signal handlers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • unix.c

    r2a1c27f r0483e1e  
    147147                struct passwd *pw = NULL;
    148148                pw = getpwnam(global.conf->user);
    149                 if (pw) {
    150                         initgroups(global.conf->user, pw->pw_gid);
    151                         setgid(pw->pw_gid);
    152                         setuid(pw->pw_uid);
    153                 } else {
    154                         log_message(LOGLVL_WARNING, "Failed to look up user %s.", global.conf->user);
     149                if (!pw) {
     150                        log_message(LOGLVL_ERROR, "Failed to look up user %s.", global.conf->user);
     151
     152                } else if (initgroups(global.conf->user, pw->pw_gid) != 0) {
     153                        log_message(LOGLVL_ERROR, "initgroups: %s.", strerror(errno));
     154
     155                } else if (setgid(pw->pw_gid) != 0) {
     156                        log_message(LOGLVL_ERROR, "setgid(%d): %s.", pw->pw_gid, strerror(errno));
     157
     158                } else if (setuid(pw->pw_uid) != 0) {
     159                        log_message(LOGLVL_ERROR, "setuid(%d): %s.", pw->pw_uid, strerror(errno));
    155160                }
    156161        }
     
    281286static void sighandler_shutdown(int signal)
    282287{
     288        int unused G_GNUC_UNUSED;
    283289        /* Write a single null byte to the pipe, just to send a message to the main loop.
    284290         * This gets handled by bitlbee_shutdown (the b_input_add callback for this pipe) */
    285         write(shutdown_pipe.fd[1], "", 1);
     291        unused = write(shutdown_pipe.fd[1], "", 1);
    286292}
    287293
     
    292298{
    293299        GSList *l;
     300        int unused G_GNUC_UNUSED;
    294301        const char *message = "ERROR :BitlBee crashed! (SIGSEGV received)\r\n";
    295302        int len = strlen(message);
     
    298305                irc_t *irc = l->data;
    299306                sock_make_blocking(irc->fd);
    300                 write(irc->fd, message, len);
     307                unused = write(irc->fd, message, len);
    301308        }
    302309
Note: See TracChangeset for help on using the changeset viewer.