#28 Fix some of compiler warnings
Merged 4 years ago by abbra. Opened 4 years ago by slev.
slev/slapi-nis fix_some_warnings  into  master

file modified
+2
@@ -849,6 +849,8 @@ 

  		request_set(state->request_info, RQ_DAEMON,

  			    DEFAULT_TCPWRAP_NAME);

  	}

+ #else

+         (void)tmp;

  #endif

  	use_be_txns = backend_shr_get_vattr_boolean(state, our_entry,

  						    "nsslapd-pluginbetxn",

file modified
+3 -5
@@ -56,7 +56,7 @@ 

  idview_get_overrides(struct backend_search_cbdata *cbdata)

  {

  	char *dn = NULL;

- 	int ret = 0, result = 0;

+ 	int result = 0;

  	const Slapi_DN *suffix = NULL;

  	Slapi_PBlock *pb;

  
@@ -76,7 +76,7 @@ 

  	slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_SUBTREE,

  				     "(objectclass=ipaOverrideAnchor)", NULL, 0,

  				     NULL, NULL, cbdata->state->plugin_identity, 0);

- 	ret = slapi_search_internal_pb(pb);

+ 	slapi_search_internal_pb(pb);

  	slapi_ch_free_string(&dn);

  	slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);

  
@@ -411,8 +411,6 @@ 

  {

  	struct backend_search_filter_config config =

  		{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL, NULL, NULL};

- 	int res = 0;

- 

  	if (cbdata->idview == NULL) {

  		return;

  	}
@@ -421,7 +419,7 @@ 

  	config.callback_data = cbdata;

  

  	/* Ignore the return code as it will always be SLAPI_FILTER_SCAN_NO_MORE */

- 	res = backend_analyze_search_filter(cbdata->filter, &config);

+ 	(void)backend_analyze_search_filter(cbdata->filter, &config);

  

  	if (config.name != NULL) {

  		slapi_ch_free_string(&config.name);

file modified
+2 -7
@@ -438,13 +438,8 @@ 

  	 * plugin want to override the values using the configuration, they

  	 * can. */

  	if (gmtime_r(&timestamp, &timestamp_tm) == &timestamp_tm) {

- 		sprintf(timestamp_str, "%04d%02d%02d%02d%02d%02dZ",

- 			timestamp_tm.tm_year + 1900,

- 			timestamp_tm.tm_mon + 1,

- 			timestamp_tm.tm_mday,

- 			timestamp_tm.tm_hour,

- 			timestamp_tm.tm_min,

- 			timestamp_tm.tm_sec);

+ 		strftime(timestamp_str, sizeof(timestamp_str),

+ 			 "%Y%m%d%H%M%SZ", &timestamp_tm);

  		slapi_entry_add_string(e, "createTimestamp", timestamp_str);

  		slapi_entry_add_string(e, "modifyTimestamp", timestamp_str);

  	}

file modified
-2
@@ -780,8 +780,6 @@ 

  backend_shr_data_initialize_thread(time_t when, void *arg)

  {

  	struct backend_shr_data_init_cbdata *cbdata = (struct backend_shr_data_init_cbdata *)arg;

- 	PRThread *thread = NULL;

- 

  	if (slapi_is_shutting_down()) {

  		return;

  	}

file modified
+2 -2
@@ -967,7 +967,7 @@ 

  	AUTH *request_auth, *reply_auth;

  	char auth_buf[MAX_AUTH_BYTES];

  	struct rpc_msg request, reply;

- 	int auth_flavor, auth_len;

+ 	int auth_flavor;

  	struct ypresp_val reply_val;

  	struct ypresp_key_val reply_key_val;

  	struct ypresp_all reply_all;
@@ -1057,7 +1057,7 @@ 

  	}

  	auth_marshall(reply_auth, &auth_xdrs);

  	auth_destroy(reply_auth);

- 	auth_len = xdr_getpos(&auth_xdrs);

+ 	(void)xdr_getpos(&auth_xdrs);

  	xdr_destroy(&auth_xdrs);

  	slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,

  			"built reply authenticator\n");

file modified
+12 -3
@@ -77,7 +77,8 @@ 

  int

  main(int argc, char **argv)

  {

- 	int s, ret, port;

+ 	int s, port;

+ 	int ret __attribute__ ((unused));

  	s = socket(PF_INET, SOCK_DGRAM, 0);

  	if (s == -1) {

  		printf("error allocating socket\n");
@@ -94,8 +95,16 @@ 

  		printf("error creating portmap/rpcbind client socket\n");

  		return 1;

  	}

- 	setregid(2516, 2516);

- 	setreuid(2510, 2510);

+ 	if (setregid(2516, 2516) == -1) {

+ 		printf("error setting real and effective group id %s\n",

+ 		       strerror(errno));

+ 		return 1;

+ 	}

+ 	if (setreuid(2510, 2510) == -1) {

+ 		printf("error setting real and effective user id %s\n",

+ 		       strerror(errno));

+ 		return 1;

+ 	}

  	sleep(60);

  	portmap_unregister("portmap", &s, port, YPPROG, YPVERS,

  			   AF_INET, IPPROTO_TCP, 0);

file modified
+3 -2
@@ -153,13 +153,14 @@ 

  wrap_stop_thread(struct wrapped_thread *t)

  {

  	void *returned = NULL;

+ 	int ret __attribute__ ((unused));

  #ifdef USE_PTHREADS

- 	write(t->stopfd[1], "", 1);

+ 	ret = write(t->stopfd[1], "", 1);

  	close(t->stopfd[1]);

  	pthread_join(t->tid, &returned);

  #endif

  #ifdef USE_NSPR_THREADS

- 	write(t->stopfd[1], "", 1);

+ 	ret = write(t->stopfd[1], "", 1);

  	close(t->stopfd[1]);

  	PR_JoinThread(t->tid);

  	returned = t->args.result;

file modified
+1 -1
@@ -12,7 +12,7 @@ 

  	$(RPCGEN) -h -o $@ $^

  yp_xdr.c: ../../yp/yp.x

  	$(RM) -f $@

- 	$(RPCGEN) -c -o $@ $^

+ 	$(RPCGEN) -c -i 0 -o $@ $^

  yp_clnt.c: ../../yp/yp.x

  	$(RM) -f $@

  	$(RPCGEN) -l -o $@ $^

file modified
+1 -2
@@ -164,8 +164,7 @@ 

  static int

  all(CLIENT *client, FILE *output, int argc, char **argv)

  {

- 	ypresp_all *ret;

- 	int i, sock;

+ 	int sock;

  	ypreq_nokey nokey;

  	struct rpc_msg req, rep;

  	struct ypresp_all resp;

file modified
+1 -1
@@ -7,7 +7,7 @@ 

  	$(RPCGEN) -h -o $@ $^

  yp_xdr.c: yp.x

  	$(RM) -f $@

- 	$(RPCGEN) -c -o $@ $^

+ 	$(RPCGEN) -c -i 0 -o $@ $^

  yp_clnt.c: yp.x

  	$(RM) -f $@

  	$(RPCGEN) -l -o $@ $^

This is just a fix for some of the annoying compiler warnings.

rebased onto 982dc8c0628264a9211a923ed5b29164dad38d6f

4 years ago

I'm not sure this is correct way -- we probably need to touch the structure but I haven't completed yet reviewing what happens with specific auth mechanisms, is there a side-effect in getting the position. Perhaps, doing (void) xdr_getpos(..) would be enough here?

If we link with tirpc, then
tirpc/rpc/xdr.h

#define xdr_getpos(xdrs)                                \                       
        (*(xdrs)->x_ops->x_getpostn)(xdrs) 

src/xdr_sizeof.c

static u_int                                                                    
x_getpostn(xdrs)                                                                
        XDR *xdrs;                                                              
{                                                                               
        return (xdrs->x_handy);                                                 
} 

There is no side effect.
But you are right, (void) is enough. The decision is up to you.

Could you please update with (void)?

rebased onto a8881e4

4 years ago

Pull-Request has been merged by abbra

4 years ago