Mark res_counter_charge(_locked) with __must_check
PATCH 1/1 Mark res_counter_charge(_locked) with __must_check
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 :) )
---
include/linux/res_counter.h +4 -2
@@ -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
Quoted 11 lines · On Thu, 08 May 2008 13:05:44 +0400 Pavel Emelyanov <[email protected]> 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 <[email protected]>
nice check :)
BTW, res_counter_charge_locked() should be extern function ?
Thanks,
-Kame
Quoted 7 lines · KAMEZAWA Hiroyuki
Quoted 4 lines · On Thu, 08 May 2008 13:05:44 +0400 Pavel Emelyanov <[email protected]> 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).
Quoted 8 lines
Quoted 7 lines
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 <[email protected]>nice check :)
Thanks!
Quoted 1 line
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 ;)
Quoted 4 lines
Thanks,
-Kame
Quoted 6 lines · On Thu, 08 May 2008 13:40:53 +0400 Pavel Emelyanov <[email protected]> wrote:
Quoted 1 line
BTW,
res_counter_charge_locked()should be extern function ?What do you mean? It is extern as well as the
res_counter_chargeand 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
Quoted 10 lines · KAMEZAWA Hiroyuki
Quoted 5 lines · On Thu, 08 May 2008 13:40:53 +0400 Pavel Emelyanov <[email protected]> wrote:
Quoted 1 line
BTW,
res_counter_charge_locked()should be extern function ?What do you mean? It is extern as well as the
res_counter_chargeand uncharge ones are, but functions may have forward declarations w/o extern keyword AFAIK ;)Ah,
Isres_counter_charge_locked()is called from files other thanres_counter.c?
I checked - everything was OK.
Quoted 1 line
Does we need declaration in header file ?
But this patch _is_ for declaration in header :)
Quoted 4 lines
Thanks,
-Kame