Blob Blame History Raw
From a8881e4cbb006fd317ecf89f006747c4dd1c84a4 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <slev@altlinux.org>
Date: Tue, 11 Jun 2019 16:54:01 +0300
Subject: [PATCH 1/2] Fix some of compiler warnings

Signed-off-by: Stanislav Levin <slev@altlinux.org>
---
 src/back-nis.c            |  2 ++
 src/back-sch-idview.c     |  8 +++-----
 src/back-sch.c            |  9 ++-------
 src/back-shr.c            |  2 --
 src/nis.c                 |  4 ++--
 src/portmap.c             | 15 ++++++++++++---
 src/wrap.c                |  5 +++--
 tests/clients/Makefile.am |  2 +-
 tests/clients/yp.c        |  3 +--
 yp/Makefile.am            |  2 +-
 10 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/back-nis.c b/src/back-nis.c
index 244beba..adf378e 100644
--- a/src/back-nis.c
+++ b/src/back-nis.c
@@ -849,6 +849,8 @@ backend_update_params(Slapi_PBlock *pb, struct plugin_state *state)
 		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",
diff --git a/src/back-sch-idview.c b/src/back-sch-idview.c
index e83fb1d..6769e8d 100644
--- a/src/back-sch-idview.c
+++ b/src/back-sch-idview.c
@@ -56,7 +56,7 @@ void
 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 @@ idview_get_overrides(struct backend_search_cbdata *cbdata)
 	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 @@ idview_replace_filter(struct backend_search_cbdata *cbdata)
 {
 	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 @@ idview_replace_filter(struct backend_search_cbdata *cbdata)
 	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);
diff --git a/src/back-sch.c b/src/back-sch.c
index f6211bc..3f7e30f 100644
--- a/src/back-sch.c
+++ b/src/back-sch.c
@@ -438,13 +438,8 @@ backend_set_operational_attributes(Slapi_Entry *e,
 	 * 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);
 	}
diff --git a/src/back-shr.c b/src/back-shr.c
index 472846a..0c29d1f 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -780,8 +780,6 @@ static void
 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;
 	}
diff --git a/src/nis.c b/src/nis.c
index 82b4c63..845c9da 100644
--- a/src/nis.c
+++ b/src/nis.c
@@ -967,7 +967,7 @@ nis_process_request(struct plugin_state *state,
 	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 @@ nis_process_request(struct plugin_state *state,
 	}
 	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");
diff --git a/src/portmap.c b/src/portmap.c
index f2e009e..bf700d9 100644
--- a/src/portmap.c
+++ b/src/portmap.c
@@ -77,7 +77,8 @@ slapi_log_error(int i, char *f, char *fmt, ...)
 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 @@ main(int argc, char **argv)
 		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);
diff --git a/src/wrap.c b/src/wrap.c
index f8056a4..2905f84 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -153,13 +153,14 @@ void *
 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;
diff --git a/tests/clients/Makefile.am b/tests/clients/Makefile.am
index b5326da..6415d02 100644
--- a/tests/clients/Makefile.am
+++ b/tests/clients/Makefile.am
@@ -12,7 +12,7 @@ yp.h: ../../yp/yp.x
 	$(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 $@ $^
diff --git a/tests/clients/yp.c b/tests/clients/yp.c
index bc2da1f..88d2b81 100644
--- a/tests/clients/yp.c
+++ b/tests/clients/yp.c
@@ -164,8 +164,7 @@ writejunk(char *fd, char *data, int size)
 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;
diff --git a/yp/Makefile.am b/yp/Makefile.am
index a75aa22..a4b4e4b 100644
--- a/yp/Makefile.am
+++ b/yp/Makefile.am
@@ -7,7 +7,7 @@ yp.h: yp.x
 	$(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 $@ $^
-- 
2.21.0