9eb798
From a8881e4cbb006fd317ecf89f006747c4dd1c84a4 Mon Sep 17 00:00:00 2001
9eb798
From: Stanislav Levin <slev@altlinux.org>
9eb798
Date: Tue, 11 Jun 2019 16:54:01 +0300
9eb798
Subject: [PATCH 1/2] Fix some of compiler warnings
9eb798
9eb798
Signed-off-by: Stanislav Levin <slev@altlinux.org>
9eb798
---
9eb798
 src/back-nis.c            |  2 ++
9eb798
 src/back-sch-idview.c     |  8 +++-----
9eb798
 src/back-sch.c            |  9 ++-------
9eb798
 src/back-shr.c            |  2 --
9eb798
 src/nis.c                 |  4 ++--
9eb798
 src/portmap.c             | 15 ++++++++++++---
9eb798
 src/wrap.c                |  5 +++--
9eb798
 tests/clients/Makefile.am |  2 +-
9eb798
 tests/clients/yp.c        |  3 +--
9eb798
 yp/Makefile.am            |  2 +-
9eb798
 10 files changed, 27 insertions(+), 25 deletions(-)
9eb798
9eb798
diff --git a/src/back-nis.c b/src/back-nis.c
9eb798
index 244beba..adf378e 100644
9eb798
--- a/src/back-nis.c
9eb798
+++ b/src/back-nis.c
9eb798
@@ -849,6 +849,8 @@ backend_update_params(Slapi_PBlock *pb, struct plugin_state *state)
9eb798
 		request_set(state->request_info, RQ_DAEMON,
9eb798
 			    DEFAULT_TCPWRAP_NAME);
9eb798
 	}
9eb798
+#else
9eb798
+        (void)tmp;
9eb798
 #endif
9eb798
 	use_be_txns = backend_shr_get_vattr_boolean(state, our_entry,
9eb798
 						    "nsslapd-pluginbetxn",
9eb798
diff --git a/src/back-sch-idview.c b/src/back-sch-idview.c
9eb798
index e83fb1d..6769e8d 100644
9eb798
--- a/src/back-sch-idview.c
9eb798
+++ b/src/back-sch-idview.c
9eb798
@@ -56,7 +56,7 @@ void
9eb798
 idview_get_overrides(struct backend_search_cbdata *cbdata)
9eb798
 {
9eb798
 	char *dn = NULL;
9eb798
-	int ret = 0, result = 0;
9eb798
+	int result = 0;
9eb798
 	const Slapi_DN *suffix = NULL;
9eb798
 	Slapi_PBlock *pb;
9eb798
 
9eb798
@@ -76,7 +76,7 @@ idview_get_overrides(struct backend_search_cbdata *cbdata)
9eb798
 	slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_SUBTREE,
9eb798
 				     "(objectclass=ipaOverrideAnchor)", NULL, 0,
9eb798
 				     NULL, NULL, cbdata->state->plugin_identity, 0);
9eb798
-	ret = slapi_search_internal_pb(pb);
9eb798
+	slapi_search_internal_pb(pb);
9eb798
 	slapi_ch_free_string(&dn;;
9eb798
 	slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
9eb798
 
9eb798
@@ -411,8 +411,6 @@ idview_replace_filter(struct backend_search_cbdata *cbdata)
9eb798
 {
9eb798
 	struct backend_search_filter_config config =
9eb798
 		{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL, NULL, NULL};
9eb798
-	int res = 0;
9eb798
-
9eb798
 	if (cbdata->idview == NULL) {
9eb798
 		return;
9eb798
 	}
9eb798
@@ -421,7 +419,7 @@ idview_replace_filter(struct backend_search_cbdata *cbdata)
9eb798
 	config.callback_data = cbdata;
9eb798
 
9eb798
 	/* Ignore the return code as it will always be SLAPI_FILTER_SCAN_NO_MORE */
9eb798
-	res = backend_analyze_search_filter(cbdata->filter, &config);
9eb798
+	(void)backend_analyze_search_filter(cbdata->filter, &config);
9eb798
 
9eb798
 	if (config.name != NULL) {
9eb798
 		slapi_ch_free_string(&config.name);
9eb798
diff --git a/src/back-sch.c b/src/back-sch.c
9eb798
index f6211bc..3f7e30f 100644
9eb798
--- a/src/back-sch.c
9eb798
+++ b/src/back-sch.c
9eb798
@@ -438,13 +438,8 @@ backend_set_operational_attributes(Slapi_Entry *e,
9eb798
 	 * plugin want to override the values using the configuration, they
9eb798
 	 * can. */
9eb798
 	if (gmtime_r(&timestamp, &timestamp_tm) == &timestamp_tm) {
9eb798
-		sprintf(timestamp_str, "%04d%02d%02d%02d%02d%02dZ",
9eb798
-			timestamp_tm.tm_year + 1900,
9eb798
-			timestamp_tm.tm_mon + 1,
9eb798
-			timestamp_tm.tm_mday,
9eb798
-			timestamp_tm.tm_hour,
9eb798
-			timestamp_tm.tm_min,
9eb798
-			timestamp_tm.tm_sec);
9eb798
+		strftime(timestamp_str, sizeof(timestamp_str),
9eb798
+			 "%Y%m%d%H%M%SZ", &timestamp_tm);
9eb798
 		slapi_entry_add_string(e, "createTimestamp", timestamp_str);
9eb798
 		slapi_entry_add_string(e, "modifyTimestamp", timestamp_str);
9eb798
 	}
9eb798
diff --git a/src/back-shr.c b/src/back-shr.c
9eb798
index 472846a..0c29d1f 100644
9eb798
--- a/src/back-shr.c
9eb798
+++ b/src/back-shr.c
9eb798
@@ -780,8 +780,6 @@ static void
9eb798
 backend_shr_data_initialize_thread(time_t when, void *arg)
9eb798
 {
9eb798
 	struct backend_shr_data_init_cbdata *cbdata = (struct backend_shr_data_init_cbdata *)arg;
9eb798
-	PRThread *thread = NULL;
9eb798
-
9eb798
 	if (slapi_is_shutting_down()) {
9eb798
 		return;
9eb798
 	}
9eb798
diff --git a/src/nis.c b/src/nis.c
9eb798
index 82b4c63..845c9da 100644
9eb798
--- a/src/nis.c
9eb798
+++ b/src/nis.c
9eb798
@@ -967,7 +967,7 @@ nis_process_request(struct plugin_state *state,
9eb798
 	AUTH *request_auth, *reply_auth;
9eb798
 	char auth_buf[MAX_AUTH_BYTES];
9eb798
 	struct rpc_msg request, reply;
9eb798
-	int auth_flavor, auth_len;
9eb798
+	int auth_flavor;
9eb798
 	struct ypresp_val reply_val;
9eb798
 	struct ypresp_key_val reply_key_val;
9eb798
 	struct ypresp_all reply_all;
9eb798
@@ -1057,7 +1057,7 @@ nis_process_request(struct plugin_state *state,
9eb798
 	}
9eb798
 	auth_marshall(reply_auth, &auth_xdrs);
9eb798
 	auth_destroy(reply_auth);
9eb798
-	auth_len = xdr_getpos(&auth_xdrs);
9eb798
+	(void)xdr_getpos(&auth_xdrs);
9eb798
 	xdr_destroy(&auth_xdrs);
9eb798
 	slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
9eb798
 			"built reply authenticator\n");
9eb798
diff --git a/src/portmap.c b/src/portmap.c
9eb798
index f2e009e..bf700d9 100644
9eb798
--- a/src/portmap.c
9eb798
+++ b/src/portmap.c
9eb798
@@ -77,7 +77,8 @@ slapi_log_error(int i, char *f, char *fmt, ...)
9eb798
 int
9eb798
 main(int argc, char **argv)
9eb798
 {
9eb798
-	int s, ret, port;
9eb798
+	int s, port;
9eb798
+	int ret __attribute__ ((unused));
9eb798
 	s = socket(PF_INET, SOCK_DGRAM, 0);
9eb798
 	if (s == -1) {
9eb798
 		printf("error allocating socket\n");
9eb798
@@ -94,8 +95,16 @@ main(int argc, char **argv)
9eb798
 		printf("error creating portmap/rpcbind client socket\n");
9eb798
 		return 1;
9eb798
 	}
9eb798
-	setregid(2516, 2516);
9eb798
-	setreuid(2510, 2510);
9eb798
+	if (setregid(2516, 2516) == -1) {
9eb798
+		printf("error setting real and effective group id %s\n",
9eb798
+		       strerror(errno));
9eb798
+		return 1;
9eb798
+	}
9eb798
+	if (setreuid(2510, 2510) == -1) {
9eb798
+		printf("error setting real and effective user id %s\n",
9eb798
+		       strerror(errno));
9eb798
+		return 1;
9eb798
+	}
9eb798
 	sleep(60);
9eb798
 	portmap_unregister("portmap", &s, port, YPPROG, YPVERS,
9eb798
 			   AF_INET, IPPROTO_TCP, 0);
9eb798
diff --git a/src/wrap.c b/src/wrap.c
9eb798
index f8056a4..2905f84 100644
9eb798
--- a/src/wrap.c
9eb798
+++ b/src/wrap.c
9eb798
@@ -153,13 +153,14 @@ void *
9eb798
 wrap_stop_thread(struct wrapped_thread *t)
9eb798
 {
9eb798
 	void *returned = NULL;
9eb798
+	int ret __attribute__ ((unused));
9eb798
 #ifdef USE_PTHREADS
9eb798
-	write(t->stopfd[1], "", 1);
9eb798
+	ret = write(t->stopfd[1], "", 1);
9eb798
 	close(t->stopfd[1]);
9eb798
 	pthread_join(t->tid, &returned);
9eb798
 #endif
9eb798
 #ifdef USE_NSPR_THREADS
9eb798
-	write(t->stopfd[1], "", 1);
9eb798
+	ret = write(t->stopfd[1], "", 1);
9eb798
 	close(t->stopfd[1]);
9eb798
 	PR_JoinThread(t->tid);
9eb798
 	returned = t->args.result;
9eb798
diff --git a/tests/clients/Makefile.am b/tests/clients/Makefile.am
9eb798
index b5326da..6415d02 100644
9eb798
--- a/tests/clients/Makefile.am
9eb798
+++ b/tests/clients/Makefile.am
9eb798
@@ -12,7 +12,7 @@ yp.h: ../../yp/yp.x
9eb798
 	$(RPCGEN) -h -o $@ $^
9eb798
 yp_xdr.c: ../../yp/yp.x
9eb798
 	$(RM) -f $@
9eb798
-	$(RPCGEN) -c -o $@ $^
9eb798
+	$(RPCGEN) -c -i 0 -o $@ $^
9eb798
 yp_clnt.c: ../../yp/yp.x
9eb798
 	$(RM) -f $@
9eb798
 	$(RPCGEN) -l -o $@ $^
9eb798
diff --git a/tests/clients/yp.c b/tests/clients/yp.c
9eb798
index bc2da1f..88d2b81 100644
9eb798
--- a/tests/clients/yp.c
9eb798
+++ b/tests/clients/yp.c
9eb798
@@ -164,8 +164,7 @@ writejunk(char *fd, char *data, int size)
9eb798
 static int
9eb798
 all(CLIENT *client, FILE *output, int argc, char **argv)
9eb798
 {
9eb798
-	ypresp_all *ret;
9eb798
-	int i, sock;
9eb798
+	int sock;
9eb798
 	ypreq_nokey nokey;
9eb798
 	struct rpc_msg req, rep;
9eb798
 	struct ypresp_all resp;
9eb798
diff --git a/yp/Makefile.am b/yp/Makefile.am
9eb798
index a75aa22..a4b4e4b 100644
9eb798
--- a/yp/Makefile.am
9eb798
+++ b/yp/Makefile.am
9eb798
@@ -7,7 +7,7 @@ yp.h: yp.x
9eb798
 	$(RPCGEN) -h -o $@ $^
9eb798
 yp_xdr.c: yp.x
9eb798
 	$(RM) -f $@
9eb798
-	$(RPCGEN) -c -o $@ $^
9eb798
+	$(RPCGEN) -c -i 0 -o $@ $^
9eb798
 yp_clnt.c: yp.x
9eb798
 	$(RM) -f $@
9eb798
 	$(RPCGEN) -l -o $@ $^
9eb798
-- 
9eb798
2.21.0
9eb798