diff options
| author | dequis <dx@dxzone.com.ar> | 2016-11-28 16:26:16 -0300 | 
|---|---|---|
| committer | dequis <dx@dxzone.com.ar> | 2016-11-28 16:26:16 -0300 | 
| commit | 0483e1e6e3954787058aff78223cb758f0074f2d (patch) | |
| tree | 887ef672f103c08cdb25e3f48a8e01adcf636c94 | |
| parent | 2a1c27f7d49e5065d4af598848bb3810bcf65e93 (diff) | |
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.
| -rw-r--r-- | protocols/msn/msn_util.c | 2 | ||||
| -rw-r--r-- | protocols/msn/soap.c | 4 | ||||
| -rw-r--r-- | protocols/nogaim.c | 2 | ||||
| -rw-r--r-- | unix.c | 23 | 
4 files changed, 19 insertions, 12 deletions
| diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 763b2768..af00e461 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -179,7 +179,7 @@ void msn_queue_feed(struct msn_data *h, char *bytes, int st)  	if (getenv("BITLBEE_DEBUG")) {  		fprintf(stderr, "\n\x1b[92m<<< "); -		write(2, bytes , st); +		fwrite(bytes, st, 1, stderr);  		fprintf(stderr, "\x1b[97m");  	}  } diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 1fa22d13..14aaed11 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -212,9 +212,9 @@ static void msn_soap_debug_print(const char *headers, const char *payload)  	if (headers) {  		if ((s = strstr(headers, "\r\n\r\n"))) { -			write(2, headers, s - headers + 4); +			fwrite(headers, s - headers + 4, 1, stderr);  		} else { -			write(2, headers, strlen(headers)); +			fwrite(headers, strlen(headers), 1, stderr);  		}  	} diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 2f6b3783..e4db7024 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -53,7 +53,7 @@ gboolean load_plugin(char *path)  {  	GList *l;  	struct plugin_info *i; -	struct plugin_info *info; +	struct plugin_info *info = NULL;  	struct plugin_info * (*info_function) (void) = NULL;  	void (*init_function) (void); @@ -146,12 +146,17 @@ int main(int argc, char *argv[])  	    (!getuid() || !geteuid())) {  		struct passwd *pw = NULL;  		pw = getpwnam(global.conf->user); -		if (pw) { -			initgroups(global.conf->user, pw->pw_gid); -			setgid(pw->pw_gid); -			setuid(pw->pw_uid); -		} else { -			log_message(LOGLVL_WARNING, "Failed to look up user %s.", global.conf->user); +		if (!pw) { +			log_message(LOGLVL_ERROR, "Failed to look up user %s.", global.conf->user); + +		} else if (initgroups(global.conf->user, pw->pw_gid) != 0) { +			log_message(LOGLVL_ERROR, "initgroups: %s.", strerror(errno)); + +		} else if (setgid(pw->pw_gid) != 0) { +			log_message(LOGLVL_ERROR, "setgid(%d): %s.", pw->pw_gid, strerror(errno)); + +		} else if (setuid(pw->pw_uid) != 0) { +			log_message(LOGLVL_ERROR, "setuid(%d): %s.", pw->pw_uid, strerror(errno));  		}  	} @@ -280,9 +285,10 @@ void sighandler_shutdown_setup()  /* Signal handler for SIGTERM and SIGINT */  static void sighandler_shutdown(int signal)  { +	int unused G_GNUC_UNUSED;  	/* Write a single null byte to the pipe, just to send a message to the main loop.  	 * This gets handled by bitlbee_shutdown (the b_input_add callback for this pipe) */ -	write(shutdown_pipe.fd[1], "", 1); +	unused = write(shutdown_pipe.fd[1], "", 1);  }  /* Signal handler for SIGSEGV @@ -291,13 +297,14 @@ static void sighandler_shutdown(int signal)  static void sighandler_crash(int signal)  {  	GSList *l; +	int unused G_GNUC_UNUSED;  	const char *message = "ERROR :BitlBee crashed! (SIGSEGV received)\r\n";  	int len = strlen(message);  	for (l = irc_connection_list; l; l = l->next) {  		irc_t *irc = l->data;  		sock_make_blocking(irc->fd); -		write(irc->fd, message, len); +		unused = write(irc->fd, message, len);  	}  	raise(signal); | 
