Changeset 0483e1e


Ignore:
Timestamp:
2016-11-28T19:26:16Z (3 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.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn_util.c

    r2a1c27f r0483e1e  
    180180        if (getenv("BITLBEE_DEBUG")) {
    181181                fprintf(stderr, "\n\x1b[92m<<< ");
    182                 write(2, bytes , st);
     182                fwrite(bytes, st, 1, stderr);
    183183                fprintf(stderr, "\x1b[97m");
    184184        }
  • protocols/msn/soap.c

    r2a1c27f r0483e1e  
    213213        if (headers) {
    214214                if ((s = strstr(headers, "\r\n\r\n"))) {
    215                         write(2, headers, s - headers + 4);
     215                        fwrite(headers, s - headers + 4, 1, stderr);
    216216                } else {
    217                         write(2, headers, strlen(headers));
     217                        fwrite(headers, strlen(headers), 1, stderr);
    218218                }
    219219        }
  • protocols/nogaim.c

    r2a1c27f r0483e1e  
    5454        GList *l;
    5555        struct plugin_info *i;
    56         struct plugin_info *info;
     56        struct plugin_info *info = NULL;
    5757        struct plugin_info * (*info_function) (void) = NULL;
    5858        void (*init_function) (void);
  • 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.