* [PATCH] Mark res_counter_charge(_locked) with __must_check
@ 2008-05-08 9:05 Pavel Emelyanov
2008-05-08 9:40 ` KAMEZAWA Hiroyuki
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Emelyanov @ 2008-05-08 9:05 UTC (permalink / raw)
To: Andrew Morton
Cc: Balbir Singh, Paul Menage, KAMEZAWA Hiroyuki,
Linux Kernel Mailing List
Ignoring theirs return value may result in counter underflow
in the future - when the value charged will be uncharged (or in
"leaks" - when the value is not uncharged).
This also prevents from using charging routines to decrement the
counter value (i.e. uncharge it) ;)
(Current code works OK with res_counter, however :) )
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index 6d9e1fc..125660e 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -95,8 +95,10 @@ void res_counter_init(struct res_counter *counter);
* counter->limit _locked call expects the counter->lock to be taken
*/
-int res_counter_charge_locked(struct res_counter *counter, unsigned long val);
-int res_counter_charge(struct res_counter *counter, unsigned long val);
+int __must_check res_counter_charge_locked(struct res_counter *counter,
+ unsigned long val);
+int __must_check res_counter_charge(struct res_counter *counter,
+ unsigned long val);
/*
* uncharge - tell that some portion of the resource is released
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Mark res_counter_charge(_locked) with __must_check
2008-05-08 9:05 [PATCH] Mark res_counter_charge(_locked) with __must_check Pavel Emelyanov
@ 2008-05-08 9:40 ` KAMEZAWA Hiroyuki
2008-05-08 9:40 ` Pavel Emelyanov
0 siblings, 1 reply; 5+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-05-08 9:40 UTC (permalink / raw)
To: Pavel Emelyanov
Cc: Andrew Morton, Balbir Singh, Paul Menage,
Linux Kernel Mailing List
On Thu, 08 May 2008 13:05:44 +0400
Pavel Emelyanov <xemul@openvz.org> wrote:
> Ignoring theirs return value may result in counter underflow
> in the future - when the value charged will be uncharged (or in
> "leaks" - when the value is not uncharged).
>
> This also prevents from using charging routines to decrement the
> counter value (i.e. uncharge it) ;)
>
> (Current code works OK with res_counter, however :) )
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
>
nice check :)
BTW, res_counter_charge_locked() should be extern function ?
Thanks,
-Kame
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Mark res_counter_charge(_locked) with __must_check
2008-05-08 9:40 ` KAMEZAWA Hiroyuki
@ 2008-05-08 9:40 ` Pavel Emelyanov
2008-05-09 0:15 ` KAMEZAWA Hiroyuki
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Emelyanov @ 2008-05-08 9:40 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki
Cc: Andrew Morton, Balbir Singh, Paul Menage,
Linux Kernel Mailing List
KAMEZAWA Hiroyuki wrote:
> On Thu, 08 May 2008 13:05:44 +0400
> Pavel Emelyanov <xemul@openvz.org> wrote:
>
>> Ignoring theirs return value may result in counter underflow
>> in the future - when the value charged will be uncharged (or in
>> "leaks" - when the value is not uncharged).
>>
>> This also prevents from using charging routines to decrement the
>> counter value (i.e. uncharge it) ;)
>>
>> (Current code works OK with res_counter, however :) )
>>
>> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
>>
> nice check :)
Thanks!
> BTW, res_counter_charge_locked() should be extern function ?
What do you mean? It is extern as well as the res_counter_charge
and uncharge ones are, but functions may have forward declarations
w/o extern keyword AFAIK ;)
> Thanks,
> -Kame
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Mark res_counter_charge(_locked) with __must_check
2008-05-08 9:40 ` Pavel Emelyanov
@ 2008-05-09 0:15 ` KAMEZAWA Hiroyuki
2008-05-12 7:08 ` Pavel Emelyanov
0 siblings, 1 reply; 5+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-05-09 0:15 UTC (permalink / raw)
To: Pavel Emelyanov
Cc: Andrew Morton, Balbir Singh, Paul Menage,
Linux Kernel Mailing List
On Thu, 08 May 2008 13:40:53 +0400
Pavel Emelyanov <xemul@openvz.org> wrote:
> > BTW, res_counter_charge_locked() should be extern function ?
>
> What do you mean? It is extern as well as the res_counter_charge
> and uncharge ones are, but functions may have forward declarations
> w/o extern keyword AFAIK ;)
>
Ah,
Is res_counter_charge_locked() is called from files other than res_counter.c ?
Does we need declaration in header file ?
Thanks,
-Kame
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Mark res_counter_charge(_locked) with __must_check
2008-05-09 0:15 ` KAMEZAWA Hiroyuki
@ 2008-05-12 7:08 ` Pavel Emelyanov
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Emelyanov @ 2008-05-12 7:08 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki
Cc: Andrew Morton, Balbir Singh, Paul Menage,
Linux Kernel Mailing List
KAMEZAWA Hiroyuki wrote:
> On Thu, 08 May 2008 13:40:53 +0400
> Pavel Emelyanov <xemul@openvz.org> wrote:
>
>>> BTW, res_counter_charge_locked() should be extern function ?
>> What do you mean? It is extern as well as the res_counter_charge
>> and uncharge ones are, but functions may have forward declarations
>> w/o extern keyword AFAIK ;)
>>
> Ah,
> Is res_counter_charge_locked() is called from files other than res_counter.c ?
I checked - everything was OK.
> Does we need declaration in header file ?
But this patch _is_ for declaration in header :)
> Thanks,
> -Kame
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-05-12 7:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-08 9:05 [PATCH] Mark res_counter_charge(_locked) with __must_check Pavel Emelyanov
2008-05-08 9:40 ` KAMEZAWA Hiroyuki
2008-05-08 9:40 ` Pavel Emelyanov
2008-05-09 0:15 ` KAMEZAWA Hiroyuki
2008-05-12 7:08 ` Pavel Emelyanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox