Bug 1377560 - Compiler warning: unused variable 'i' [-Wunused-variable]
Summary: Compiler warning: unused variable 'i' [-Wunused-variable]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: rpcbind
Version: 7.3
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Steve Dickson
QA Contact: ChunYu Wang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-20 06:12 UTC by ChunYu Wang
Modified: 2017-08-01 18:36 UTC (History)
3 users (show)

Fixed In Version: rpcbind-0.2.0-39.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 18:36:03 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:1992 0 normal SHIPPED_LIVE rpcbind bug fix update 2017-08-01 18:10:39 UTC

Comment 4 ChunYu Wang 2017-02-27 08:19:15 UTC
If we just delete this declaration of 'i', the other 'i' instances in for loops will get error with undeclared variable 'i', maybe it is better to change i = 0 into int i = 0 in each loop, this will both avoid the original unused 'i' problem and comply to C99 standard.
 
[chunwang@fs-qe src]$ cat ./rpcb_svc_com.c  |egrep SVC_RUN_DEBUG -A 5
#ifdef SVC_RUN_DEBUG
	int i;
#endif
	register struct pollfd	*p;
	fd_set cleanfds;

--
#ifdef SVC_RUN_DEBUG
		if (debugging) {
			fprintf(stderr, "polling for read on fd < ");
			for (i = 0, p = pollfds; i < nfds; i++, p++)
				if (p->events)
					fprintf(stderr, "%d ", p->fd);
--
#ifdef SVC_RUN_DEBUG
			if (debugging) {
				fprintf(stderr, "poll returned read fds < ");
				for (i = 0, p = pollfds; i < nfds; i++, p++)
					if (p->revents)
						fprintf(stderr, "%d ", p->fd);
--
<--snip-->
[chunwang@fs-qe rpcbind]$ cat ./rpcbind-0.2.0-i-warn.patch
diff -up rpcbind-0.2.0/src/rpcb_svc_com.c.orig rpcbind-0.2.0/src/rpcb_svc_com.c
--- rpcbind-0.2.0/src/rpcb_svc_com.c.orig	2017-02-25 14:47:09.839325988 -0500
+++ rpcbind-0.2.0/src/rpcb_svc_com.c	2017-02-25 14:47:57.424187563 -0500
@@ -1106,9 +1106,6 @@ my_svc_run()
 	struct pollfd pollfds[FD_SETSIZE];
 	int poll_ret, check_ret;
 	int n;
-#ifdef SVC_RUN_DEBUG
-	int i;
-#endif
 	register struct pollfd	*p;
 	fd_set cleanfds;

Comment 5 Steve Dickson 2017-02-27 23:09:02 UTC
(In reply to ChunYu Wang from comment #4)
> If we just delete this declaration of 'i', the other 'i' instances in for
> loops will get error with undeclared variable 'i', maybe it is better to
> change i = 0 into int i = 0 in each loop, this will both avoid the original
> unused 'i' problem and comply to C99 standard.
No. If that was true there would not have been a warning.
Plus those other SVC_RUN_DEBUG are in different routine.

Comment 7 ChunYu Wang 2017-03-13 03:24:57 UTC
Moved to VERIFIED according to Comment 6, will keep an eye on related issues in future erratas.

Comment 8 errata-xmlrpc 2017-08-01 18:36:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1992


Note You need to log in before you can comment on or make changes to this bug.