linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used
@ 2011-04-05 16:02 Justin P. Mattock
  2011-04-11 18:56 ` Randy Dunlap
  2011-04-13  0:26 ` Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: Justin P. Mattock @ 2011-04-05 16:02 UTC (permalink / raw)
  To: rdunlap; +Cc: linux-doc, linux-kernel, Justin P. Mattock

The below patch takes care of the warning, but keep in mind am unsure if this is a correct way
to resolve this issue.
Documentation/accounting/getdelays.c: In function ‘main’:
Documentation/accounting/getdelays.c:436:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]

Keep in mind there is another warning with this file, but need am unsure what might be the best solution:
Documentation/accounting/getdelays.c: In function ‘get_family_id’:
Documentation/accounting/getdelays.c:172:14: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]

 Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>

---
 Documentation/accounting/getdelays.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index e9c7778..16e16d5 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -433,8 +433,6 @@ int main(int argc, char *argv[])
 	}
 
 	do {
-		int i;
-
 		rep_len = recv(nl_sd, &msg, sizeof(msg), 0);
 		PRINTF("received %d bytes\n", rep_len);
 
@@ -459,7 +457,6 @@ int main(int argc, char *argv[])
 
 		na = (struct nlattr *) GENLMSG_DATA(&msg);
 		len = 0;
-		i = 0;
 		while (len < rep_len) {
 			len += NLA_ALIGN(na->nla_len);
 			switch (na->nla_type) {
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used
  2011-04-05 16:02 [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used Justin P. Mattock
@ 2011-04-11 18:56 ` Randy Dunlap
  2011-04-12  1:49   ` Justin P. Mattock
  2011-04-13  0:26 ` Andrew Morton
  1 sibling, 1 reply; 7+ messages in thread
From: Randy Dunlap @ 2011-04-11 18:56 UTC (permalink / raw)
  To: Justin P. Mattock; +Cc: linux-doc, linux-kernel

On Tue,  5 Apr 2011 09:02:50 -0700 Justin P. Mattock wrote:

> The below patch takes care of the warning, but keep in mind am unsure if this is a correct way
> to resolve this issue.
> Documentation/accounting/getdelays.c: In function ‘main’:
> Documentation/accounting/getdelays.c:436:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]
> 
> Keep in mind there is another warning with this file, but need am unsure what might be the best solution:
> Documentation/accounting/getdelays.c: In function ‘get_family_id’:
> Documentation/accounting/getdelays.c:172:14: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]

Hi,
Does -Wunused-but-set-variable require gcc 4.6.0?


>  Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
> 
> ---
>  Documentation/accounting/getdelays.c |    3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
> index e9c7778..16e16d5 100644
> --- a/Documentation/accounting/getdelays.c
> +++ b/Documentation/accounting/getdelays.c
> @@ -433,8 +433,6 @@ int main(int argc, char *argv[])
>  	}
>  
>  	do {
> -		int i;
> -
>  		rep_len = recv(nl_sd, &msg, sizeof(msg), 0);
>  		PRINTF("received %d bytes\n", rep_len);
>  
> @@ -459,7 +457,6 @@ int main(int argc, char *argv[])
>  
>  		na = (struct nlattr *) GENLMSG_DATA(&msg);
>  		len = 0;
> -		i = 0;
>  		while (len < rep_len) {
>  			len += NLA_ALIGN(na->nla_len);
>  			switch (na->nla_type) {
> -- 


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used
  2011-04-11 18:56 ` Randy Dunlap
@ 2011-04-12  1:49   ` Justin P. Mattock
  0 siblings, 0 replies; 7+ messages in thread
From: Justin P. Mattock @ 2011-04-12  1:49 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-doc, linux-kernel

On 04/11/2011 11:56 AM, Randy Dunlap wrote:
> On Tue,  5 Apr 2011 09:02:50 -0700 Justin P. Mattock wrote:
>
>> The below patch takes care of the warning, but keep in mind am unsure if this is a correct way
>> to resolve this issue.
>> Documentation/accounting/getdelays.c: In function ‘main’:
>> Documentation/accounting/getdelays.c:436:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]
>>
>> Keep in mind there is another warning with this file, but need am unsure what might be the best solution:
>> Documentation/accounting/getdelays.c: In function ‘get_family_id’:
>> Documentation/accounting/getdelays.c:172:14: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
>
> Hi,
> Does -Wunused-but-set-variable require gcc 4.6.0?
>
>

not sure.. think its part of the whole "have gcc debug and clean things 
while it builds" feature with 4.6.0

>>   Signed-off-by: Justin P. Mattock<justinmattock@gmail.com>
>>
>> ---
>>   Documentation/accounting/getdelays.c |    3 ---
>>   1 files changed, 0 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
>> index e9c7778..16e16d5 100644
>> --- a/Documentation/accounting/getdelays.c
>> +++ b/Documentation/accounting/getdelays.c
>> @@ -433,8 +433,6 @@ int main(int argc, char *argv[])
>>   	}
>>
>>   	do {
>> -		int i;
>> -
>>   		rep_len = recv(nl_sd,&msg, sizeof(msg), 0);
>>   		PRINTF("received %d bytes\n", rep_len);
>>
>> @@ -459,7 +457,6 @@ int main(int argc, char *argv[])
>>
>>   		na = (struct nlattr *) GENLMSG_DATA(&msg);
>>   		len = 0;
>> -		i = 0;
>>   		while (len<  rep_len) {
>>   			len += NLA_ALIGN(na->nla_len);
>>   			switch (na->nla_type) {
>> --
>
>
> ---
> ~Randy
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used
  2011-04-05 16:02 [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used Justin P. Mattock
  2011-04-11 18:56 ` Randy Dunlap
@ 2011-04-13  0:26 ` Andrew Morton
  2011-04-13  0:44   ` Justin P. Mattock
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2011-04-13  0:26 UTC (permalink / raw)
  To: Justin P. Mattock; +Cc: rdunlap, linux-doc, linux-kernel, Balbir Singh

On Tue,  5 Apr 2011 09:02:50 -0700
"Justin P. Mattock" <justinmattock@gmail.com> wrote:

> Keep in mind there is another warning with this file, but need am unsure what might be the best solution:
> Documentation/accounting/getdelays.c: In function ___get_family_id___:
> Documentation/accounting/getdelays.c:172:14: warning: variable ___rc___ set but not used [-Wunused-but-set-variable]

this?


Subject: Documentation/accounting/getdelays.c: handle sendto() failures
From: Andrew Morton <akpm@linux-foundation.org>

Documentation/accounting/getdelays.c: In function `get_family_id':
Documentation/accounting/getdelays.c:172:14: warning: variable `rc' set but not used [-Wunused-but-set-variable]

Reported-by: "Justin P. Mattock" <justinmattock@gmail.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 Documentation/accounting/getdelays.c |    2 ++
 1 file changed, 2 insertions(+)

diff -puN Documentation/accounting/getdelays.c~documentation-accounting-getdelaysc-handle-sendto-failures Documentation/accounting/getdelays.c
--- a/Documentation/accounting/getdelays.c~documentation-accounting-getdelaysc-handle-sendto-failures
+++ a/Documentation/accounting/getdelays.c
@@ -177,6 +177,8 @@ static int get_family_id(int sd)
 	rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
 			CTRL_ATTR_FAMILY_NAME, (void *)name,
 			strlen(TASKSTATS_GENL_NAME)+1);
+	if (rc < 0)
+		return 0;	/* sendto() failure? */
 
 	rep_len = recv(sd, &ans, sizeof(ans), 0);
 	if (ans.n.nlmsg_type == NLMSG_ERROR ||
_


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used
  2011-04-13  0:26 ` Andrew Morton
@ 2011-04-13  0:44   ` Justin P. Mattock
  2011-04-13  1:18     ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Justin P. Mattock @ 2011-04-13  0:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: rdunlap, linux-doc, linux-kernel, Balbir Singh

On 04/12/2011 05:26 PM, Andrew Morton wrote:
> On Tue,  5 Apr 2011 09:02:50 -0700
> "Justin P. Mattock"<justinmattock@gmail.com>  wrote:
>
>> Keep in mind there is another warning with this file, but need am unsure what might be the best solution:
>> Documentation/accounting/getdelays.c: In function ___get_family_id___:
>> Documentation/accounting/getdelays.c:172:14: warning: variable ___rc___ set but not used [-Wunused-but-set-variable]
>
> this?

there was two warnings with that one..(or atleast that what I am seeing 
over here).

>
>
> Subject: Documentation/accounting/getdelays.c: handle sendto() failures
> From: Andrew Morton<akpm@linux-foundation.org>
>
> Documentation/accounting/getdelays.c: In function `get_family_id':
> Documentation/accounting/getdelays.c:172:14: warning: variable `rc' set but not used [-Wunused-but-set-variable]
>
> Reported-by: "Justin P. Mattock"<justinmattock@gmail.com>
> Cc: Balbir Singh<balbir@in.ibm.com>
> Signed-off-by: Andrew Morton<akpm@linux-foundation.org>
> ---
>
>   Documentation/accounting/getdelays.c |    2 ++
>   1 file changed, 2 insertions(+)
>
> diff -puN Documentation/accounting/getdelays.c~documentation-accounting-getdelaysc-handle-sendto-failures Documentation/accounting/getdelays.c
> --- a/Documentation/accounting/getdelays.c~documentation-accounting-getdelaysc-handle-sendto-failures
> +++ a/Documentation/accounting/getdelays.c
> @@ -177,6 +177,8 @@ static int get_family_id(int sd)
>   	rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
>   			CTRL_ATTR_FAMILY_NAME, (void *)name,
>   			strlen(TASKSTATS_GENL_NAME)+1);
> +	if (rc<  0)
> +		return 0;	/* sendto() failure? */
>
>   	rep_len = recv(sd,&ans, sizeof(ans), 0);
>   	if (ans.n.nlmsg_type == NLMSG_ERROR ||
> _
>
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used
  2011-04-13  0:44   ` Justin P. Mattock
@ 2011-04-13  1:18     ` Andrew Morton
  2011-04-13  1:30       ` Justin P. Mattock
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2011-04-13  1:18 UTC (permalink / raw)
  To: Justin P. Mattock; +Cc: rdunlap, linux-doc, linux-kernel, Balbir Singh

On Tue, 12 Apr 2011 17:44:49 -0700 "Justin P. Mattock" <justinmattock@gmail.com> wrote:

> On 04/12/2011 05:26 PM, Andrew Morton wrote:
> > On Tue,  5 Apr 2011 09:02:50 -0700
> > "Justin P. Mattock"<justinmattock@gmail.com>  wrote:
> >
> >> Keep in mind there is another warning with this file, but need am unsure what might be the best solution:
> >> Documentation/accounting/getdelays.c: In function ___get_family_id___:
> >> Documentation/accounting/getdelays.c:172:14: warning: variable ___rc___ set but not used [-Wunused-but-set-variable]
> >
> > this?
> 
> there was two warnings with that one..(or atleast that what I am seeing 
> over here).

I don't know what you mean.

What command(s) are you using to build getdelays.o, btw?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used
  2011-04-13  1:18     ` Andrew Morton
@ 2011-04-13  1:30       ` Justin P. Mattock
  0 siblings, 0 replies; 7+ messages in thread
From: Justin P. Mattock @ 2011-04-13  1:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: rdunlap, linux-doc, linux-kernel, Balbir Singh

On 04/12/2011 06:18 PM, Andrew Morton wrote:
> On Tue, 12 Apr 2011 17:44:49 -0700 "Justin P. Mattock"<justinmattock@gmail.com>  wrote:
>
>> On 04/12/2011 05:26 PM, Andrew Morton wrote:
>>> On Tue,  5 Apr 2011 09:02:50 -0700
>>> "Justin P. Mattock"<justinmattock@gmail.com>   wrote:
>>>
>>>> Keep in mind there is another warning with this file, but need am unsure what might be the best solution:
>>>> Documentation/accounting/getdelays.c: In function ___get_family_id___:
>>>> Documentation/accounting/getdelays.c:172:14: warning: variable ___rc___ set but not used [-Wunused-but-set-variable]
>>>
>>> this?
>>
>> there was two warnings with that one..(or atleast that what I am seeing
>> over here).
>
> I don't know what you mean.
>
> What command(s) are you using to build getdelays.o, btw?
>

the two warnings while building getdelays
to build the kernel I just do:
"make"

part of the log here:
http://fpaste.org/eXmq/

system is fedora 15. .config is theirs as well

Justin P. Mattock

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-04-13  1:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-05 16:02 [RFC]Documentation:accounting:getdelays.c Fix: warning: variable ‘i’ set but not used Justin P. Mattock
2011-04-11 18:56 ` Randy Dunlap
2011-04-12  1:49   ` Justin P. Mattock
2011-04-13  0:26 ` Andrew Morton
2011-04-13  0:44   ` Justin P. Mattock
2011-04-13  1:18     ` Andrew Morton
2011-04-13  1:30       ` Justin P. Mattock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).