Fix gcc 4.6.0 set but not used warning messages.
Subsystems (10)
cover Fix gcc 4.6.0 set but not used warning messages.
First and foremost, I must
thank anybody taking the time to even look at these(I know you people have better things to be doing).
And secondly here is my try at trying to fix some of the warning messages spammed by gcc 4.6.0 when building the kernel. Some of them I removed, and some of them I just shut off.
Note: Removing the code does seem like a good approach(if it's actually dead), but if not then something needs
to be fixed.
As for shutting off the code to shutup gcc does seem like a temporary fix, but would rather have a warning message, than see it get lost in the sands of time.
In any case Thanks for taking the time, and hopefully we can get fixes for all of this mess generated by gcc..
Justin P. Mattock
PATCH 1/8 reiserfs:stree.c Fix variable set but not used.
Not sure if this is correct or not.
the below patch gets rid of this warning message
produced by gcc 4.6.0
fs/reiserfs/stree.c: In function 'search_by_key':fs/reiserfs/stree.c:602:6: warning: variable 'right_neighbor_of_leaf_node' set but not used
--- fs/reiserfs/stree.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
fs/reiserfs/stree.c +2 -5
@@ -599,7 +599,6 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to sstruct buffer_head *bh;struct path_element *last_element;int node_level, retval; -int right_neighbor_of_leaf_node;int fs_gen;struct buffer_head *reada_bh[SEARCH_BY_KEY_READA ];b_blocknr_t reada_blocks[SEARCH_BY_KEY_READA ];
@@ -617,8 +616,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to spathrelse (search_path); - right_neighbor_of_leaf_node =0 ; - +/* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */
@@ -695,8 +693,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to sstarting from the root. */ block_number =SB_ROOT_BLOCK (sb); expected_level =-1 ; - right_neighbor_of_leaf_node =0 ; - +/* repeat search from the root */ continue ; }
Signature · 1 line
1.7.1.rc1.21.gf3bd6
PATCH 2/8 bluetooth/hci_ldisc.c Fix warning: variable 'tty' set but not used
In reply to Justin P. MattockIm getting this while building:
CC [M] drivers/bluetooth/hci_ldisc.odrivers/bluetooth/hci_ldisc.c: In function 'hci_uart_send_frame':drivers/bluetooth/hci_ldisc.c:213:21: warning: variable 'tty' set but not used
the below fixed it for me, but am not sure if
it's correct.
--- drivers/bluetooth/hci_ldisc.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/bluetooth/hci_ldisc.c +1 -3
@@ -210,7 +210,6 @@ static int hci_uart_close(struct hci_dev *hdev)static int hci_uart_send_frame (struct sk_buff *skb) {struct hci_dev * hdev = (struct hci_dev *) skb->dev; -struct tty_struct *tty;struct hci_uart *hu;if (!hdev) {
@@ -222,8 +221,7 @@ static int hci_uart_send_frame(struct sk_buff *skb)return -EBUSY ; hu = (struct hci_uart *) hdev->driver_data; - tty = hu->tty; - +BT_DBG ("%s: type %d len %d" , hdev->name,bt_cb (skb)->pkt_type, skb->len); hu->proto->enqueue (hu, skb);
Signature · 8 lines
1.7.1.rc1.21.gf3bd6 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
PATCH 3/8 char/hpet.c Fix variable 'hpet' set but not used
In reply to Justin P. MattockThe below fixes this warning:drivers/char/hpet.c: In function 'hpet_ioctl_common':drivers/char/hpet.c:559:23: warning: variable 'hpet' set but not used
please have a look.
--- drivers/char/hpet.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/char/hpet.c +0 -2
@@ -556,7 +556,6 @@ static int hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) { struct hpet_timer __iomem *timer; -struct hpet __iomem *hpet;struct hpets *hpetp;int err;unsigned long v;
@@ -568,7 +567,6 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)case HPET_DPI :case HPET_IRQFREQ : timer = devp->hd_timer; - hpet = devp->hd_hpet; hpetp = devp->hd_hpets;break ;case HPET_IE_ON :
Signature · 8 lines
1.7.1.rc1.21.gf3bd6 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
PATCH 4/8 drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to Justin P. MattockIm getting this warning when compiling:
CC drivers/char/tpm/tpm.odrivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not used
The below patch gets rid of the warning,
but I'm not sure if it's the best solution.
--- drivers/char/tpm/tpm.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/char/tpm/tpm.c +2 -0
@@ -514,6 +514,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip) rc =transmit_cmd (chip, &tpm_cmd,TPM_INTERNAL_RESULT_SIZE ,"attempting to determine the timeouts" ); +if (!rc) + rc =0 ; }EXPORT_SYMBOL_GPL (tpm_gen_interrupt);
Signature · 8 lines
1.7.1.rc1.21.gf3bd6 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
PATCH 5/8 drm:drm_gem Fix warning: variable 'dev' set but not used
In reply to Justin P. MattockProbably not even a fix for this warning:
CC [M] drivers/gpu/drm/drm_gem.odrivers/gpu/drm/drm_gem.c: In function 'drm_gem_handle_delete':drivers/gpu/drm/drm_gem.c:188:21: warning: variable 'dev' set but not used
--- drivers/gpu/drm/drm_gem.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_gem.c +2 -0
@@ -206,6 +206,8 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)return -EINVAL ; } dev = obj->dev; +if (!dev) + dev =0 ;/* Release reference and decrement refcount. */ idr_remove (&filp->object_idr, handle);
Signature · 8 lines
1.7.1.rc1.21.gf3bd6 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
PATCH 6/8 i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to Justin P. Mattockcould be a right solution, could be wrong
here is the warning:
CC drivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not used
--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/i2c/i2c-core.c +2 -0
@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;mutex_unlock (&core_lock);return 0 ;
Signature · 8 lines
1.7.1.rc1.21.gf3bd6 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
PATCH 7/8 ieee1394/sdp2 Fix warning: variable 'unit_characteristics' set but not used
In reply to Justin P. MattockTemporary fix until something is resolved
to fix the below warning:
CC [M] drivers/ieee1394/sbp2.odrivers/ieee1394/sbp2.c: In function 'sbp2_parse_unit_directory':drivers/ieee1394/sbp2.c:1353:6: warning: variable 'unit_characteristics' set but not used
--- drivers/ieee1394/sbp2.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/ieee1394/sbp2.c +2 -0
@@ -1356,6 +1356,8 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu, management_agent_addr =0 ; unit_characteristics =0 ; +if (!unit_characteristics) + unit_characteristics =0 ; firmware_revision =SBP2_ROM_VALUE_MISSING ; model = ud->flags &UNIT_DIRECTORY_MODEL_ID ? ud->model_id :SBP2_ROM_VALUE_MISSING ;
Signature · 8 lines
1.7.1.rc1.21.gf3bd6 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
PATCH 8/8 tuners:tuner-simple Fix warning: variable 'tun' set but not used
In reply to Justin P. Mattocknot sure if this is correct or not for
fixing this warning:
CC [M] drivers/media/common/tuners/tuner-simple.odrivers/media/common/tuners/tuner-simple.c: In function 'simple_set_tv_freq':drivers/media/common/tuners/tuner-simple.c:548:20: warning: variable 'tun' set but not used
--- drivers/media/common/tuners/tuner-simple.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/media/common/tuners/tuner-simple.c +1 -3
@@ -545,14 +545,12 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,struct tuner_simple_priv *priv = fe->tuner_priv;u8 config, cb;u16 div; -struct tunertype *tun;u8 buffer[4 ];int rc, IFPCoff, i;enum param_type desired_type;struct tuner_params *t_params; - tun = priv->tun; - +/* IFPCoff = Video Intermediate Frequency - Vif: 940 =16*58.75 NTSC/J (Japan) 732 =16*45.75 M/N STD
Signature · 8 lines
1.7.1.rc1.21.gf3bd6 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to Justin P. Mattockfs/reiserfs/stree.c int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s · line 619
Quoted 7 lines · Justin P. Mattock
fs/reiserfs/stree.c +1
-2@@ -617,8 +616,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to spathrelse (search_path); - right_neighbor_of_leaf_node =0 ; - +
This hunk introduces whitespace on the empty line, which is not cool.
fs/reiserfs/stree.c int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s · line 696
Quoted 10 lines
fs/reiserfs/stree.c +1
-2/* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */ @@ -695,8 +693,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to sstarting from the root. */ block_number =SB_ROOT_BLOCK (sb); expected_level =-1 ; - right_neighbor_of_leaf_node =0 ; - +
Here, too.
Most of the patches in this series have similar issues.
Signature · 1 line
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to Justin P. MattockHi Justin,
Quoted 17 lines · Justin P. Mattock
could be a right solution, could be wrong
here is the warning:
CCdrivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not usedSigned-off-by Justin P. Mattock <[email protected]>--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +0
-0
drivers/i2c/i2c-core.c static int i2c_register_adapter(struct i2c_adapter *adap) · line 798
Quoted 5 lines
drivers/i2c/i2c-core.c +2
-0@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;
One word: scripts/checkpatch.pl
In other news, the above is just plain wrong. First we force people to read the result of bus_for_each_drv() and then when they do and don't need the value, gcc complains, so we add one more layer of useless code, which developers and possibly tools will later wonder and complain about? I can easily imagine that a static code analyzer would spot the above code as being a potential bug.
Let's stop this madness now please.
Either __must_check goes away from bus_for_each_drv() and from every other function which raises this problem, or we must disable that new type of warning gcc 4.6.0 generates. Depends which warnings we value more, as we can't sanely have both.
Quoted 3 lines
drivers/i2c/i2c-core.c +0
-0mutex_unlock (&core_lock);return 0 ;
Signature · 1 line
Jean Delvare
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to Justin P. MattockQuoted 9 lines · Justin P. Mattock
Not sure if this is correct or not.
the below patch gets rid of this warning message
produced by gcc 4.6.0
fs/reiserfs/stree.c: In function 'search_by_key':fs/reiserfs/stree.c:602:6: warning: variable 'right_neighbor_of_leaf_node' set but not usedSigned-off-by Justin P. Mattock <[email protected]>
Quoted 37 lines
--- fs/reiserfs/stree.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)fs/reiserfs/stree.c +2
-5@@ -599,7 +599,6 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to sstruct buffer_head *bh;struct path_element *last_element;int node_level, retval; -int right_neighbor_of_leaf_node;int fs_gen;struct buffer_head *reada_bh[SEARCH_BY_KEY_READA ];b_blocknr_t reada_blocks[SEARCH_BY_KEY_READA ];@@ -617,8 +616,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to spathrelse (search_path); - right_neighbor_of_leaf_node =0 ; - +/* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */ @@ -695,8 +693,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to sstarting from the root. */ block_number =SB_ROOT_BLOCK (sb); expected_level =-1 ; - right_neighbor_of_leaf_node =0 ; - +/* repeat search from the root */ continue ; }
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to Jean DelvareQuoted 15 lines · Jean Delvare
Hi Justin,
Quoted 12 lines · Justin P. Mattock
could be a right solution, could be wrong
here is the warning:
CCdrivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 12 lines
drivers/i2c/i2c-core.c static int i2c_register_adapter(struct i2c_adapter *adap) · line 798
Quoted 10 lines
drivers/i2c/i2c-core.c +2
-0@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;One word:
scripts/checkpatch.pl
it was this, and/or just take the code out
(since I'm a newbie)
Quoted 10 lines
In other news, the above is just plain wrong. First we force people to read the result of
bus_for_each_drv()and then when they do and don't need the value, gcc complains, so we add one more layer of useless code, which developers and possibly tools will later wonder and complain about? I can easily imagine that a static code analyzer would spot the above code as being a potential bug.Let's stop this madness now please.
your telling me!! I haven't even compiled all the way through the kernel yet.(lots of warnings)
Quoted 10 lines
Either
__must_checkgoes away frombus_for_each_drv()and from every other function which raises this problem, or we must disable that new type of warning gcc 4.6.0 generates. Depends which warnings we value more, as we can't sanely have both.Quoted 3 lines
drivers/i2c/i2c-core.c +0
-0mutex_unlock (&core_lock);return 0 ;
up to you guys..
best thing now is deciphering what
and what not is an actual issue.
Justin P. Mattock
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to Nick BowlerQuoted 10 lines · Nick Bowler
fs/reiserfs/stree.c int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s · line 619
Quoted 7 lines · Justin P. Mattock
fs/reiserfs/stree.c +1
-2@@ -617,8 +616,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to spathrelse (search_path); - right_neighbor_of_leaf_node =0 ; - +This hunk introduces whitespace on the empty line, which is not cool.
I can resend!!(biggest problem is working through these warnings)
Quoted 14 lines
fs/reiserfs/stree.c int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s · line 696
Quoted 11 lines
fs/reiserfs/stree.c +1
-2/* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */ @@ -695,8 +693,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to sstarting from the root. */ block_number =SB_ROOT_BLOCK (sb); expected_level =-1 ; - right_neighbor_of_leaf_node =0 ; - +Here, too.
Quoted 2 lines
Most of the patches in this series have similar issues.
main thing now(for me atleast)is, is this actual dead code or what? if not then something else needs to be done, if yes then I guess I can resend this, with out the whitespace issue.
Justin P. Mattock
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to a message not in the archiveQuoted 10 lines · Nick Bowler
fs/reiserfs/stree.c int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s · line 619
Quoted 7 lines · Justin P. Mattock
fs/reiserfs/stree.c +1
-2@@ -617,8 +616,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to spathrelse (search_path); - right_neighbor_of_leaf_node =0 ; - +This hunk introduces whitespace on the empty line, which is not cool.
I can resend!!(biggest problem is working through these warnings)
Quoted 14 lines
fs/reiserfs/stree.c int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s · line 696
Quoted 11 lines
fs/reiserfs/stree.c +1
-2/* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */ @@ -695,8 +693,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to sstarting from the root. */ block_number =SB_ROOT_BLOCK (sb); expected_level =-1 ; - right_neighbor_of_leaf_node =0 ; - +Here, too.
Quoted 2 lines
Most of the patches in this series have similar issues.
main thing now(for me atleast)is, is this actual dead code or what? if not then something else needs to be done, if yes then I guess I can resend this, with out the whitespace issue.
Justin P. Mattock
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to Edward ShishkinQuoted 5 lines · Edward Shishkin
Quoted 4 lines · Justin P. Mattock
Not sure if this is correct or not.
the below patch gets rid of this warning message
produced by gcc 4.6.0
Quoted 8 lines
Quoted 5 lines
fs/reiserfs/stree.c: In function 'search_by_key':fs/reiserfs/stree.c:602:6: warning: variable
'right_neighbor_of_leaf_node' set but not usedSigned-off-by Justin P. Mattock <[email protected]>Acked-by Edward Shishkin <[email protected]>
o.k.!!
what about the whitespace issue?
from what I remember I did notice the "+" that git does when making patches like this but given some many of these warnings I just did a quick workaround or however then figured to worry later on that.
Quoted 41 lines
Quoted 39 lines
---
fs/reiserfs/stree.c| 7 ++-----1 files changed, 2 insertions(+), 5 deletions(-)fs/reiserfs/stree.c +0
-0@@ -599,7 +599,6 @@ int search_by_key(struct super_block *sb, conststruct
cpu_key*key, /* Key to s
structbuffer_head*bh;
structpath_element*last_element;
intnode_level, retval;
- intright_neighbor_of_leaf_node;
intfs_gen;
structbuffer_head*reada_bh[SEARCH_BY_KEY_READA];b_blocknr_treada_blocks[SEARCH_BY_KEY_READA];fs/reiserfs/stree.c +0
-0@@ -617,8 +616,7 @@ int search_by_key(struct super_block *sb, conststruct
cpu_key*key, /* Key to s
pathrelse(search_path);-
right_neighbor_of_leaf_node= 0;fs/reiserfs/stree.c +1
-1- +/* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */
fs/reiserfs/stree.c +0
-0@@ -695,8 +693,7 @@ int search_by_key(struct super_block *sb, conststruct
cpu_key*key, /* Key to s
starting from the root. */block_number=SB_ROOT_BLOCK(sb);expected_level= -1;
-right_neighbor_of_leaf_node= 0;fs/reiserfs/stree.c +1
-1- +/* repeat search from the root */
continue;
}
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to Jean DelvareQuoted 35 lines · Jean Delvare
Hi Justin,
Quoted 17 lines · Justin P. Mattock
could be a right solution, could be wrong
here is the warning:
CCdrivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +0
-0drivers/i2c/i2c-core.c static int i2c_register_adapter(struct i2c_adapter *adap) · line 798
Quoted 5 lines
drivers/i2c/i2c-core.c +2
-0@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;One word:
scripts/checkpatch.plIn other news, the above is just plain wrong. First we force people to read the result of
bus_for_each_drv()and then when they do and don't need the value, gcc complains, so we add one more layer of useless code, which developers and possibly tools will later wonder and complain about? I can easily imagine that a static code analyzer would spot the above code as being a potential bug.
Quoted 7 lines
Let's stop this madness now please.
Either
__must_checkgoes away frombus_for_each_drv()and from every other function which raises this problem, or we must disable that new type of warning gcc 4.6.0 generates. Depends which warnings we value more, as we can't sanely have both.
That is the crux of the whole thing. Putting in crap to get rid of the __must_check warning someone obviously wanted to provoke is just plain wrong.
I don't know what the answer is, but in addition to your suggestion of removing the __must_check, you might try:
BUG_ON(dummy != WHAT_IT_SHOULD_BE);
or
if (dummy != WHAT_IT_SHOULD_BE)
panic("nice message here);or
static inline void i_really_know_what_i_am_doing(int arg)
{
/*
* Trick the compiler because we don't want to
* handle error conditions.
*/
return;
}.
.
.
i_really_know_what_i_am_doing(dummy);
David Daney
PATCH 1/1 ieee1394: sbp2: remove unused code
In reply to Justin P. Mattockwhich caused gcc 4.6 to warn about
variable 'unit_characteristics' set but not used.
The underlying problem that was spotted here --- an incomplete implementation --- is already 50% fixed in drivers/firewire/sbp2.c which observes mgt_ORB_timeout but not yet ORB_size.
--- drivers/ieee1394/sbp2.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/ieee1394/sbp2.c +4 -7
@@ -1350,12 +1350,11 @@ static void sbp2_parse_unit_directory(ststruct csr1212_keyval *kv;struct csr1212_dentry *dentry;u64 management_agent_addr; -u32 unit_characteristics, firmware_revision, model; +u32 firmware_revision, model;unsigned workarounds;int i; management_agent_addr =0 ; - unit_characteristics =0 ; firmware_revision =SBP2_ROM_VALUE_MISSING ; model = ud->flags &UNIT_DIRECTORY_MODEL_ID ? ud->model_id :SBP2_ROM_VALUE_MISSING ;
@@ -1372,17 +1371,15 @@ static void sbp2_parse_unit_directory(st lu->lun =ORB_SET_LUN (kv->value.immediate);break ; -case SBP2_UNIT_CHARACTERISTICS_KEY : -/* FIXME: This is ignored so far. -* See SBP-2 clause 7.4.8. */ - unit_characteristics = kv->value.immediate; -break ;case SBP2_FIRMWARE_REVISION_KEY : firmware_revision = kv->value.immediate;break ;default : +/* FIXME: Check for SBP2_UNIT_CHARACTERISTICS_KEY +* mgt_ORB_timeout and ORB_size, SBP-2 clause 7.4.8. */ +/* FIXME: Check for SBP2_DEVICE_TYPE_AND_LUN_KEY. * Its "ordered" bit has consequences for command ORB * list handling. See SBP-2 clauses 4.6, 7.4.11, 10.2 */
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -===- http://arcgraph.de/sr/
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to Justin P. MattockQuoted 10 lines · Justin P. Mattock
Quoted 9 lines · Edward Shishkin
Quoted 8 lines · Justin P. Mattock
Not sure if this is correct or not.
the below patch gets rid of this warning message
produced by gcc 4.6.0
fs/reiserfs/stree.c: In function 'search_by_key':fs/reiserfs/stree.c:602:6: warning: variable
'right_neighbor_of_leaf_node' set but not used
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Justin P. Mattock <[email protected]>Acked-by Edward Shishkin <[email protected]>o.k.!!
what about the whitespace issue?
Whitespaces should be removed.
I recommend quilt package for managing patches:
"quilt refresh --strip-trailing-whitespace" is your friend..
Thanks,
Edward.
Quoted 50 lines
from what I remember I did notice the "+" that git does when making patches like this but given some many of these warnings I just did a quick workaround or however then figured to worry later on that.
Quoted 41 lines
Quoted 39 lines
---
fs/reiserfs/stree.c| 7 ++-----1 files changed, 2 insertions(+), 5 deletions(-)fs/reiserfs/stree.c +0
-0@@ -599,7 +599,6 @@ int search_by_key(struct super_block *sb, conststruct
cpu_key*key, /* Key to s
structbuffer_head*bh;
structpath_element*last_element;
intnode_level, retval;
- intright_neighbor_of_leaf_node;
intfs_gen;
structbuffer_head*reada_bh[SEARCH_BY_KEY_READA];b_blocknr_treada_blocks[SEARCH_BY_KEY_READA];fs/reiserfs/stree.c +0
-0@@ -617,8 +616,7 @@ int search_by_key(struct super_block *sb, conststruct
cpu_key*key, /* Key to s
pathrelse(search_path);-
right_neighbor_of_leaf_node= 0;fs/reiserfs/stree.c +1
-1- +/* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */
fs/reiserfs/stree.c +0
-0@@ -695,8 +693,7 @@ int search_by_key(struct super_block *sb, conststruct
cpu_key*key, /* Key to s
starting from the root. */block_number=SB_ROOT_BLOCK(sb);expected_level= -1;
-right_neighbor_of_leaf_node= 0;fs/reiserfs/stree.c +1
-1- +/* repeat search from the root */
continue;
}
Re: [PATCH] ieee1394: sbp2: remove unused code
In reply to Stefan RichterQuoted 43 lines · Stefan Richter
which caused gcc 4.6 to warn about
variable 'unit_characteristics' set but not used.The underlying problem that was spotted here --- an incomplete implementation --- is already 50% fixed in
drivers/firewire/sbp2.cwhich observesmgt_ORB_timeoutbut not yetORB_size.Reported-by Justin P. Mattock<[email protected]>Signed-off-by Stefan Richter<[email protected]>--- drivers/ieee1394/sbp2.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)Index:
b/drivers/ieee1394/sbp2.c
===================================================================drivers/ieee1394/sbp2.c +1
-7@@ -1350,12 +1350,11 @@ static void sbp2_parse_unit_directory(ststruct csr1212_keyval *kv;struct csr1212_dentry *dentry;u64 management_agent_addr; -u32 unit_characteristics, firmware_revision, model; +u32 firmware_revision, model;unsigned workarounds;int i; management_agent_addr =0 ; - unit_characteristics =0 ; firmware_revision =SBP2_ROM_VALUE_MISSING ; model = ud->flags&UNIT_DIRECTORY_MODEL_ID ? ud->model_id :SBP2_ROM_VALUE_MISSING ;@@ -1372,17 +1371,15 @@ static void sbp2_parse_unit_directory(st lu->lun =ORB_SET_LUN (kv->value.immediate);break ; -case SBP2_UNIT_CHARACTERISTICS_KEY : -/* FIXME: This is ignored so far. -* See SBP-2 clause 7.4.8. */ - unit_characteristics = kv->value.immediate; -break ;case SBP2_FIRMWARE_REVISION_KEY :
drivers/ieee1394/sbp2.c static void sbp2_parse_unit_directory(st · line 1385
Quoted 10 lines
drivers/ieee1394/sbp2.c +3
-0firmware_revision = kv->value.immediate;break ;default : +/* FIXME: Check for SBP2_UNIT_CHARACTERISTICS_KEY +* mgt_ORB_timeout and ORB_size, SBP-2 clause 7.4.8. */ +/* FIXME: Check for SBP2_DEVICE_TYPE_AND_LUN_KEY. * Its "ordered" bit has consequences for command ORB * list handling. See SBP-2 clauses 4.6, 7.4.11, 10.2 */
perfect!! compiled without any warning
with that one..
thanks for the reply and patch..
FWIW if you have time there's these guys as well
that I never looked at:
CC [M] drivers/firewire/core-transaction.odrivers/firewire/core-transaction.c: In function 'fw_core_handle_response':drivers/firewire/core-transaction.c:835:21: warning: variable 'destination' set but not used
CC [M] drivers/firewire/ohci.o
CC [M] drivers/ieee1394/raw1394.odrivers/ieee1394/raw1394.c: In function 'arm_write':drivers/ieee1394/raw1394.c:1018:39: warning: variable 'length_conflict' set but not used drivers/ieee1394/raw1394.c: In function 'arm_lock64':drivers/ieee1394/raw1394.c:1373:11: warning: 'old' may be used uninitialized in this function drivers/ieee1394/raw1394.c: In function 'arm_lock':drivers/ieee1394/raw1394.c:1155:12: warning: 'old' may be used uninitialized in this function
CC [M] drivers/ieee1394/dv1394.odrivers/ieee1394/dv1394.c: In function 'frame_prepare':drivers/ieee1394/dv1394.c:613:15: warning: variable 'ts_off' set but not used drivers/ieee1394/dv1394.c: In function 'ir_tasklet_func':drivers/ieee1394/dv1394.c:2007:22: warning: variable 'packet_time' set but not used drivers/ieee1394/dv1394.c: In function 'dv1394_host_reset':drivers/ieee1394/dv1394.c:2323:18: warning: variable 'ohci' set but not used
CC [M] drivers/ieee1394/eth1394.odrivers/ieee1394/eth1394.c: In function 'ether1394_iso':drivers/ieee1394/eth1394.c:1261:23: warning: variable 'priv' set but not used
LD drivers/ieee802154/built-in.o
I can test and see!!
Justin P. Mattock
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to Edward ShishkinQuoted 19 lines · Edward Shishkin
Quoted 10 lines · Justin P. Mattock
Quoted 9 lines · Edward Shishkin
Quoted 8 lines · Justin P. Mattock
Not sure if this is correct or not.
the below patch gets rid of this warning message
produced by gcc 4.6.0
fs/reiserfs/stree.c: In function 'search_by_key':fs/reiserfs/stree.c:602:6: warning: variable
'right_neighbor_of_leaf_node' set but not usedQuoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Justin P. Mattock <[email protected]>Acked-by Edward Shishkin <[email protected]>o.k.!!
what about the whitespace issue?
Quoted 7 lines
Whitespaces should be removed.
I recommend quilt package for managing patches:
"quilt refresh --strip-trailing-whitespace" is your friend..Thanks,
Edward.
o.k. I resent this.. fixed the whitespace(hopefully) and add your Acked to it.
as for quilt I'll have to look into that.. (using a lfs system, so if the sourcecode is easy to deal with(build), then it's a good but if it becomes a nightmare maybe not!!).
Justin P. Mattock
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
Quoted 11 lines · Justin P. Mattock
Quoted 3 lines · Edward Shishkin
Whitespaces should be removed.
I recommend quilt package for managing patches:
"quilt refresh --strip-trailing-whitespace" is your friend..o.k. I resent this.. fixed the whitespace(hopefully) and add your Acked to it.
as for quilt I'll have to look into that.. (using a lfs system, so if the sourcecode is easy to deal with(build), then it's a good but if it becomes a nightmare maybe not!!).
Since you appear to generate the patches with git, you can use "git diff --check [...]" for some basic whitespace checks (additions of trailing space, additions of space before tab). For more extensive checks, try "git diff [...] | scripts/checkpatch.pl -". Check this before you commit. If you committed already, "git commit --amend [-a] [...]" lets you alter the very last commit of course.
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -==== http://arcgraph.de/sr/
which caused gcc 4.6 to warn about
variable 'destination' set but not used.
Since the hardware ensures that we receive only response packets with proper destination node ID (in a given bus generation), we have no use for destination here in the core as well as in upper layers.
(This is different with request packets. There we pass destination node ID to upper layers because they may for example need to check whether this was an unicast or broadcast request.)
--- drivers/firewire/core-transaction.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/firewire/core-transaction.c +5 -6
@@ -881,13 +881,12 @@ void fw_core_handle_response(struct fw_cunsigned long flags;u32 *data;size_t data_length; -int tcode, tlabel, destination, source, rcode; +int tcode, tlabel, source, rcode; - tcode =HEADER_GET_TCODE (p->header[0 ]); - tlabel =HEADER_GET_TLABEL (p->header[0 ]); - destination =HEADER_GET_DESTINATION (p->header[0 ]); - source =HEADER_GET_SOURCE (p->header[1 ]); - rcode =HEADER_GET_RCODE (p->header[1 ]); + tcode =HEADER_GET_TCODE (p->header[0 ]); + tlabel =HEADER_GET_TLABEL (p->header[0 ]); + source =HEADER_GET_SOURCE (p->header[1 ]); + rcode =HEADER_GET_RCODE (p->header[1 ]);spin_lock_irqsave (&card->lock, flags);list_for_each_entry (t, &card->transaction_list, link) {
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -==== http://arcgraph.de/sr/
Re:
Quoted 32 lines · Stefan Richter
which caused gcc 4.6 to warn about
variable 'destination' set but not used.Reported-by Justin P. Mattock<[email protected]>Since the hardware ensures that we receive only response packets with proper destination node ID (in a given bus generation), we have no use for destination here in the core as well as in upper layers.
(This is different with request packets. There we pass destination node ID to upper layers because they may for example need to check whether this was an unicast or broadcast request.)
Signed-off-by Stefan Richter<[email protected]>--- drivers/firewire/core-transaction.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)Index:
b/drivers/firewire/core-transaction.c
===================================================================drivers/firewire/core-transaction.c +1
-3@@ -881,13 +881,12 @@ void fw_core_handle_response(struct fw_cunsigned long flags;u32 *data;size_t data_length; -int tcode, tlabel, destination, source, rcode; +int tcode, tlabel, source, rcode; - tcode =HEADER_GET_TCODE (p->header[0 ]); - tlabel =HEADER_GET_TLABEL (p->header[0 ]);
drivers/firewire/core-transaction.c void fw_core_handle_response(struct fw_c · line 892
Quoted 10 lines
drivers/firewire/core-transaction.c +4
-3- destination =HEADER_GET_DESTINATION (p->header[0 ]); - source =HEADER_GET_SOURCE (p->header[1 ]); - rcode =HEADER_GET_RCODE (p->header[1 ]); + tcode =HEADER_GET_TCODE (p->header[0 ]); + tlabel =HEADER_GET_TLABEL (p->header[0 ]); + source =HEADER_GET_SOURCE (p->header[1 ]); + rcode =HEADER_GET_RCODE (p->header[1 ]);spin_lock_irqsave (&card->lock, flags);list_for_each_entry (t,&card->transaction_list, link) {
built good.. here's what I see now:
LD kernel/built-in.o CC [M] fs/reiserfs/stree.o LD [M] fs/reiserfs/reiserfs.o CC [M] drivers/firewire/core-transaction.o LD [M] drivers/firewire/firewire-core.o LD [M] drivers/firewire/firewire-ohci.o LD [M] drivers/firewire/firewire-sbp2.o CC [M] drivers/ieee1394/sbp2.o CC [M] drivers/net/wireless/hostap/hostap_80211_rx.o CC [M] drivers/net/wireless/hostap/hostap_80211_tx.o CC [M] drivers/net/wireless/hostap/hostap_ap.o
nice and clean!!
Justin P. Mattock
PATCH 1/1 ieee1394: remove unused variables
In reply to Justin P. Mattockwhich caused gcc 4.6 to warn about
variable 'XYZ' set but not used.
sbp2.c, unit_characteristics:
The underlying problem which was spotted here --- an incomplete implementation --- is already 50% fixed in drivers/firewire/sbp2.c which observes mgt_ORB_timeout but not yet ORB_size.
raw1394.c, length_conflict; dv1394.c, ts_off:
Impossible to tell why these variables are there. We can safely remove them though because we don't need a compiler warning to realize that we are dealing with (at least stylistically) flawed code here.
dv1394.c, packet_time:
This was used in debug macro that is only compiled in with DV1394_DEBUG_LEVEL >= 2 defined at compile-time. Just drop it since nobody debugs dv1394 anymore. Avoids noise in regular kernel builds.
dv1394.c, ohci; eth1394.c, priv:
These variables clearly can go away. Somebody wanted to use them but then didn't (or not anymore).
Note, all of this code is considered to be at its end of life and is thus not really meant to receive janitorial updates anymore. But if we can easily remove noisy warnings from kernel builds, we should.
---
Incorporates patch "ieee1394: sbp2: remove unused code".
drivers/ieee1394/dv1394.c | 14 ++------------ drivers/ieee1394/eth1394.c | 3 --- drivers/ieee1394/raw1394.c | 3 +-- drivers/ieee1394/sbp2.c | 11 ++++------- 4 files changed, 7 insertions(+), 24 deletions(-)
drivers/ieee1394/sbp2.c +4 -7
@@ -1350,12 +1350,11 @@ static void sbp2_parse_unit_directory(ststruct csr1212_keyval *kv;struct csr1212_dentry *dentry;u64 management_agent_addr; -u32 unit_characteristics, firmware_revision, model; +u32 firmware_revision, model;unsigned workarounds;int i; management_agent_addr =0 ; - unit_characteristics =0 ; firmware_revision =SBP2_ROM_VALUE_MISSING ; model = ud->flags &UNIT_DIRECTORY_MODEL_ID ? ud->model_id :SBP2_ROM_VALUE_MISSING ;
@@ -1372,17 +1371,15 @@ static void sbp2_parse_unit_directory(st lu->lun =ORB_SET_LUN (kv->value.immediate);break ; -case SBP2_UNIT_CHARACTERISTICS_KEY : -/* FIXME: This is ignored so far. -* See SBP-2 clause 7.4.8. */ - unit_characteristics = kv->value.immediate; -break ;case SBP2_FIRMWARE_REVISION_KEY : firmware_revision = kv->value.immediate;break ;default : +/* FIXME: Check for SBP2_UNIT_CHARACTERISTICS_KEY +* mgt_ORB_timeout and ORB_size, SBP-2 clause 7.4.8. */ +/* FIXME: Check for SBP2_DEVICE_TYPE_AND_LUN_KEY. * Its "ordered" bit has consequences for command ORB * list handling. See SBP-2 clauses 4.6, 7.4.11, 10.2 */
drivers/ieee1394/raw1394.c +1 -2
@@ -1015,7 +1015,7 @@ static int arm_write(struct hpsb_host *hstruct arm_addr *arm_addr =NULL ;struct arm_request *arm_req =NULL ;struct arm_response *arm_resp =NULL ; -int found =0 , size =0 , rcode =-1 , length_conflict =0 ; +int found =0 , size =0 , rcode =-1 ;struct arm_request_response *arm_req_resp =NULL ; DBGMSG("arm_write called by node: %X "
@@ -1054,7 +1054,6 @@ static int arm_write(struct hpsb_host *h }if (arm_addr->rec_length < length) {DBGMSG ("arm_write blocklength too big -> rcode_data_error" ); - length_conflict =1 ; rcode =RCODE_DATA_ERROR ;/* hardware error, data is unavailable */ }if (rcode ==-1 ) {
drivers/ieee1394/dv1394.c +2 -12
@@ -610,7 +610,7 @@ static void frame_prepare(struct video_c }else {u32 transmit_sec, transmit_cyc; -u32 ts_cyc, ts_off; +u32 ts_cyc;/* DMA is stopped, so this is the very first frame */ video->active_frame = this_frame;
@@ -636,7 +636,6 @@ static void frame_prepare(struct video_c transmit_sec += transmit_cyc/8000 ; transmit_cyc %=8000 ; - ts_off = ct_off; ts_cyc = transmit_cyc +3 ; ts_cyc %=8000 ;
@@ -2004,7 +2003,7 @@ static void ir_tasklet_func(unsigned lonint sof=0 ;/* start-of-frame flag */ struct frame *f; -u16 packet_length, packet_time; +u16 packet_length;int i, dbc=0 ;struct DMA_descriptor_block *block =NULL ;u16 xferstatus;
@@ -2024,11 +2023,6 @@ static void ir_tasklet_func(unsigned lon sizeof(struct packet)); packet_length =le16_to_cpu (p->data_length); - packet_time =le16_to_cpu (p->timestamp); - -irq_printk ("received packet %02d, timestamp=%04x, length=%04x, sof=%02x%02x\n" , video->current_packet, - packet_time, packet_length, - p->data[0 ], p->data[1 ]);/* get the descriptor based on packet_buffer cursor */ f = video->frames[video->current_packet /MAX_PACKETS ];
@@ -2320,7 +2314,6 @@ static void dv1394_add_host(struct hpsb_static void dv1394_host_reset (struct hpsb_host *host) { -struct ti_ohci *ohci;struct video_card *video =NULL , *tmp_vid;unsigned long flags;
@@ -2328,9 +2321,6 @@ static void dv1394_host_reset(struct hpsif (strcmp (host->driver->name,OHCI1394_DRIVER_NAME ))return ; - ohci = (struct ti_ohci *)host->hostdata; - -/* find the corresponding video_cards */ spin_lock_irqsave (&dv1394_cards_lock, flags);list_for_each_entry (tmp_vid, &dv1394_cards, list) {
drivers/ieee1394/eth1394.c +0 -3
@@ -1258,7 +1258,6 @@ static void ether1394_iso(struct hpsb_ischar *buf;struct eth1394_host_info *hi;struct net_device *dev; -struct eth1394_priv *priv;unsigned int len;u32 specifier_id;u16 source_id;
@@ -1288,8 +1287,6 @@ static void ether1394_iso(struct hpsb_is (be32_to_cpu (data[1 ]) &0xff000000 ) >>24 ; source_id =be32_to_cpu (data[0 ]) >>16 ; - priv =netdev_priv (dev); -if (info->channel != (iso->host->csr.broadcast_channel &0x3f ) || specifier_id !=ETHER1394_GASP_SPECIFIER_ID ) {/* This packet is not for us */
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -==== http://arcgraph.de/sr/
Re: [PATCH 1/8]reiserfs:stree.c Fix variable set but not used.
In reply to Stefan RichterQuoted 13 lines · Stefan Richter
Quoted 11 lines · Justin P. Mattock
Quoted 3 lines · Edward Shishkin
Whitespaces should be removed.
I recommend quilt package for managing patches:
"quilt refresh --strip-trailing-whitespace" is your friend..o.k. I resent this.. fixed the whitespace(hopefully) and add your Acked to it.
as for quilt I'll have to look into that.. (using a lfs system, so if the sourcecode is easy to deal with(build), then it's a good but if it becomes a nightmare maybe not!!).
Quoted 6 lines
Since you appear to generate the patches with git, you can use "git diff --check [...]" for some basic whitespace checks (additions of trailing space, additions of space before tab). For more extensive checks, try "git diff [...] |
scripts/checkpatch.pl-". Check this before you commit. If you committed already, "git commit --amend [-a] [...]" lets you alter the very last commit of course.
Thanks for the info on this, copied it
down in my book of commands...
Justin P. Mattock
Re: [PATCH] ieee1394: sbp2: remove unused code
In reply to Justin P. MattockQuoted 6 lines · Justin P. Mattock
drivers/ieee1394/raw1394.c: In function 'arm_lock64':drivers/ieee1394/raw1394.c:1373:11: warning: 'old' may be used uninitialized in this functiondrivers/ieee1394/raw1394.c: In function 'arm_lock':drivers/ieee1394/raw1394.c:1155:12: warning: 'old' may be used uninitialized in this function
Thanks. I briefly looked at this and am not sure if this is real or a false positive. This code is old crud that is really hard to read.
I will look at it again at a more convenient time of day.
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -==== http://arcgraph.de/sr/
Re: (no subject)
In reply to Stefan RichterQuoted 2 lines · Stefan Richter
which caused gcc 4.6 to warn about
variable 'destination' set but not used.
...
Quoted 2 lines
drivers/firewire/core-transaction.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
...
Subject was meant to be [PATCH] firewire: core: remove unused variable.
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -==== http://arcgraph.de/sr/
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to Justin P. Mattockdrivers/char/tpm/tpm.c void tpm_gen_interrupt(struct tpm_chip *chip) · line 519
Quoted 13 lines · Justin P. Mattock
Im getting this warning when compiling:
CCdrivers/char/tpm/tpm.odrivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not usedThe below patch gets rid of the warning,
but I'm not sure if it's the best solution.drivers/char/tpm/tpm.c +2
-0rc =transmit_cmd (chip, &tpm_cmd,TPM_INTERNAL_RESULT_SIZE ,"attempting to determine the timeouts" ); +if (!rc) + rc =0 ; }
Good thing that's a void function. ;)
Unless transmit_cmd() is marked 'must_check', maybe losing the 'rc =' would be a better solution?
Re: [PATCH 2/8]bluetooth/hci_ldisc.c Fix warning: variable 'tty' set but not used
In reply to Justin P. MattockHi Justin,
Quoted 7 lines · Justin P. Mattock
Im getting this while building:
CC [M]drivers/bluetooth/hci_ldisc.odrivers/bluetooth/hci_ldisc.c: In function 'hci_uart_send_frame':drivers/bluetooth/hci_ldisc.c:213:21: warning: variable 'tty' set but not usedthe below fixed it for me, but am not sure if
it's correct.
The fix is correct, you just need to fix the trailing whitespace problem and resend it.
Also we use "Bluetooth:" as part of the commit message on the bluetooth subsystem. For example:
"Bluetooth: Remove set but not used varible 'tty'
Or something like that.
Signature · 2 lines
Gustavo F. Padovan http://padovan.org
Re: [PATCH] ieee1394: sbp2: remove unused code
In reply to Stefan RichterQuoted 8 lines · Stefan Richter
Quoted 6 lines · Justin P. Mattock
drivers/ieee1394/raw1394.c: In function 'arm_lock64':drivers/ieee1394/raw1394.c:1373:11: warning: 'old' may be used uninitialized in this functiondrivers/ieee1394/raw1394.c: In function 'arm_lock':drivers/ieee1394/raw1394.c:1155:12: warning: 'old' may be used uninitialized in this function
Quoted 4 lines
Thanks. I briefly looked at this and am not sure if this is real or a false positive. This code is old crud that is really hard to read.
I will look at it again at a more convenient time of day.
I dont think you need to buddy!! just applied all patches you sent..
she looks like this now:
CC [M] drivers/firewire/core-card.o CC [M] drivers/firewire/core-cdev.o CC [M] drivers/firewire/core-device.o CC [M] drivers/firewire/core-iso.o CC [M] drivers/firewire/core-topology.o CC [M] drivers/firewire/core-transaction.o CC [M] drivers/firewire/ohci.o CC [M] drivers/firewire/sbp2.o LD [M] drivers/firewire/firewire-core.o LD [M] drivers/firewire/firewire-ohci.o LD [M] drivers/firewire/firewire-sbp2.o CC drivers/firmware/dmi_scan.o CC drivers/firmware/efivars.o CC drivers/firmware/dmi-id.o CC drivers/firmware/memmap.o LD drivers/firmware/built-in.o
she's clean as a whistle!!
only concern now is the
hardware and driver functioning properly i.g. I haven't installed the kernel
(if it even makes a difference)
just compiling and looking at warning messages.
cheers,
Justin P. Mattock
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to [email protected]Quoted 17 lines · On 06/14/2010 05:13 PM, [email protected] wrote:
drivers/char/tpm/tpm.c void tpm_gen_interrupt(struct tpm_chip *chip) · line 519
Quoted 13 lines · Justin P. Mattock
Im getting this warning when compiling:
CCdrivers/char/tpm/tpm.odrivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not usedThe below patch gets rid of the warning,
but I'm not sure if it's the best solution.rc = transmit_cmd(chip,&tpm_cmd,
TPM_INTERNAL_RESULT_SIZE,
"attempting to determine the timeouts");drivers/char/tpm/tpm.c +2
-0+if (!rc) + rc =0 ; }Good thing that's a void function. ;)
Quoted 2 lines
Unless
transmit_cmd()is marked 'must_check', maybe losing the 'rc =' would be a better solution?
what I tried was this:
if (!rc)
printk("test........"\n")and everything looked good,
but as a soon as I changed
rc = transmit_cmd(chip,&tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
"attempting to determine the timeouts");
to this:
rc = transmit_cmd(chip,&tpm_cmd, TPM_INTERNAL_RESULT_SIZE);
if (!rc)
printk("attempting to determine the timeouts\n");I error out with transmit_cmd not having enough functions to it.. so I just added the rc = 0; and went on to the next.
Justin P. Mattock
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
Quoted 9 lines · Justin P. Mattock
what I tried was this:
if (!rc)
printk("test........"\n")and everything looked good,
but as a soon as I changedrc = transmit_cmd(chip,&tpm_cmd,
TPM_INTERNAL_RESULT_SIZE,
Quoted 8 lines
"attempting to determine the timeouts");to this:
rc =
transmit_cmd(chip,&tpm_cmd, TPM_INTERNAL_RESULT_SIZE);if (!rc)
printk("attempting to determine the timeouts\n");
*baffled* Why did you think that would work? transmit_cmd()s signature has 4 parameters.
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
Quoted 15 lines · On 06/14/2010 08:49 PM, [email protected] wrote:
Quoted 13 lines · Justin P. Mattock
what I tried was this:
if (!rc)
printk("test........"\n")and everything looked good,
but as a soon as I changedrc = transmit_cmd(chip,&tpm_cmd,
TPM_INTERNAL_RESULT_SIZE,"attempting to determine the timeouts");to this:
Quoted 7 lines
Quoted 4 lines
rc =
transmit_cmd(chip,&tpm_cmd, TPM_INTERNAL_RESULT_SIZE);if (!rc)
printk("attempting to determine the timeouts\n");*baffled* Why did you think that would work? transmit_cmd()s signature has 4 parameters.
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is. So I kind of just scrambled with this one.
Justin P. Mattock
Re: [PATCH 8/8]tuners:tuner-simple Fix warning: variable 'tun' set but not used
In reply to Justin P. MattockEm 14-06-2010 23:26, Justin P. Mattock escreveu:
Quoted 19 lines
not sure if this is correct or not for
fixing this warning:
CC [M]drivers/media/common/tuners/tuner-simple.odrivers/media/common/tuners/tuner-simple.c: In function 'simple_set_tv_freq':drivers/media/common/tuners/tuner-simple.c:548:20: warning: variable 'tun' set but not usedSigned-off-by Justin P. Mattock <[email protected]>--- drivers/media/common/tuners/tuner-simple.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)drivers/media/common/tuners/tuner-simple.c +0
-0@@ -545,14 +545,12 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,struct tuner_simple_priv *priv = fe->tuner_priv;u8 config, cb;
drivers/media/common/tuners/tuner-simple.c static int simple_set_tv_freq(struct dvb_frontend *fe, · line 553
Quoted 10 lines
drivers/media/common/tuners/tuner-simple.c +1
-3u16 div; -struct tunertype *tun;u8 buffer[4 ];int rc, IFPCoff, i;enum param_type desired_type;struct tuner_params *t_params; - tun = priv->tun; - +
Why are you adding an extra blank line here? Except for that, the patch looks sane.
Quoted 3 lines
drivers/media/common/tuners/tuner-simple.c +0
-0/* IFPCoff = Video Intermediate Frequency - Vif: 940 =16*58.75 NTSC/J (Japan) 732 =16*45.75 M/N STD
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to Justin P. MattockQuoted 6 lines · Justin P. Mattock
Quoted 2 lines
*baffled* Why did you think that would work? transmit_cmd()s signature has 4 parameters.
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is.
Check out the tool cscope. (Or kscope, if you prefer a GUI.)
//Peter
Re: [PATCH 8/8]tuners:tuner-simple Fix warning: variable 'tun' set but not used
In reply to Mauro Carvalho ChehabQuoted 29 lines · Mauro Carvalho Chehab
Em 14-06-2010 23:26, Justin P. Mattock escreveu:
Quoted 26 lines
not sure if this is correct or not for
fixing this warning:
CC [M]drivers/media/common/tuners/tuner-simple.odrivers/media/common/tuners/tuner-simple.c: In function 'simple_set_tv_freq':drivers/media/common/tuners/tuner-simple.c:548:20: warning: variable 'tun' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/media/common/tuners/tuner-simple.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)drivers/media/common/tuners/tuner-simple.c +0
-1@@ -545,14 +545,12 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,struct tuner_simple_priv *priv = fe->tuner_priv;u8 config, cb;u16 div; -struct tunertype *tun;u8 buffer[4 ];int rc, IFPCoff, i;enum param_type desired_type;struct tuner_params *t_params;
Quoted 6 lines
drivers/media/common/tuners/tuner-simple.c static int simple_set_tv_freq(struct dvb_frontend *fe, · line 553
Quoted 3 lines
drivers/media/common/tuners/tuner-simple.c +1
-2- tun = priv->tun; - +Why are you adding an extra blank line here? Except for that, the patch looks sane.
I think I was doing something wrong when creating these patches. i.g.
I just hightlight the code then move the cursor highlight all the way to the right before pressing "x". normally would be o.k. but for some reason seems to be doing this. found if I highlight left to ; (or the end of the code I want to delete) then git commit creates the patch properly.
Quoted 5 lines
drivers/media/common/tuners/tuner-simple.c static int simple_set_tv_freq(struct dvb_frontend *fe, · line 556
Quoted 3 lines
drivers/media/common/tuners/tuner-simple.c +0
-0/* IFPCoff = Video Intermediate Frequency - Vif: 940 =16*58.75 NTSC/J (Japan) 732 =16*45.75 M/N STD
I'll resend this.
Thanks for having a look.
Justin P. Mattock
Re: [PATCH 8/8]tuners:tuner-simple Fix warning: variable 'tun' set but not used
In reply to Mauro Carvalho ChehabQuoted 29 lines · Mauro Carvalho Chehab
Em 14-06-2010 23:26, Justin P. Mattock escreveu:
Quoted 26 lines
not sure if this is correct or not for
fixing this warning:
CC [M]drivers/media/common/tuners/tuner-simple.odrivers/media/common/tuners/tuner-simple.c: In function 'simple_set_tv_freq':drivers/media/common/tuners/tuner-simple.c:548:20: warning: variable 'tun' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/media/common/tuners/tuner-simple.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)drivers/media/common/tuners/tuner-simple.c +0
-1@@ -545,14 +545,12 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,struct tuner_simple_priv *priv = fe->tuner_priv;u8 config, cb;u16 div; -struct tunertype *tun;u8 buffer[4 ];int rc, IFPCoff, i;enum param_type desired_type;struct tuner_params *t_params;
Quoted 11 lines
drivers/media/common/tuners/tuner-simple.c static int simple_set_tv_freq(struct dvb_frontend *fe, · line 553
Quoted 3 lines
drivers/media/common/tuners/tuner-simple.c +1
-2- tun = priv->tun; - +Why are you adding an extra blank line here? Except for that, the patch looks sane.
Quoted 3 lines
drivers/media/common/tuners/tuner-simple.c +0
-0/* IFPCoff = Video Intermediate Frequency - Vif: 940 =16*58.75 NTSC/J (Japan) 732 =16*45.75 M/N STD
o.k. resent this.. I ended up doing
a git reset do make sure things dont get
funky etc..
Justin P. Mattock
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to Peter StugeQuoted 4 lines · Peter Stuge
Quoted 3 lines · Justin P. Mattock
Quoted 2 lines
*baffled* Why did you think that would work? transmit_cmd()s signature has 4 parameters.
Quoted 9 lines
Quoted 3 lines
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is.
Check out the tool cscope. (Or kscope, if you prefer a GUI.)
//Peter
thanks for this tool.. I think this is what I need.. running around not knowing what/where the manual is for a call is a bit daunting. I'll give this a look.
Thanks for this..
Justin P. Mattock
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to a message not in the archiveQuoted 4 lines · Peter Stuge
Quoted 3 lines · Justin P. Mattock
Quoted 2 lines
*baffled* Why did you think that would work? transmit_cmd()s signature has 4 parameters.
Quoted 9 lines
Quoted 3 lines
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is.
Check out the tool cscope. (Or kscope, if you prefer a GUI.)
//Peter
thanks for this tool.. I think this is what I need.. running around not knowing what/where the manual is for a call is a bit daunting. I'll give this a look.
Thanks for this..
Justin P. Mattock
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to Justin P. MattockQuoted 10 lines · Justin P. Mattock
Quoted 6 lines · Peter Stuge
Quoted 3 lines · Justin P. Mattock
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is.
Check out the tool cscope. (Or kscope, if you prefer a GUI.)
thanks for this tool.. I think this is what I need.. running around not knowing what/where the manual is for a call is a bit daunting.
Similar to cscope/kscope but online:
http://lxr.free-electrons.com/
http://lxr.linux.no/linux
E.g. http://lxr.free-electrons.com/ident?i=transmit_cmd
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -==== http://arcgraph.de/sr/
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
Quoted 9 lines · Stefan Richter
Quoted 8 lines · Justin P. Mattock
Quoted 6 lines · Peter Stuge
Quoted 3 lines · Justin P. Mattock
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is.
Check out the tool cscope. (Or kscope, if you prefer a GUI.)
Quoted 8 lines
Quoted 2 lines
thanks for this tool.. I think this is what I need.. running around not knowing what/where the manual is for a call is a bit daunting.
Similar to cscope/kscope but online:
http://lxr.free-electrons.com/
http://lxr.linux.no/linux
hmm.. yeah I use those guys a lot.. with grep also.. I think what might throw me off is things like def.orig = def.new then def.orig gets lost in the mix(or it's there, but the grep becomes gigantic in code results.) main thing I look for is googling "somedefinition linux man" for some idea of what that function does.
Justin P. Mattock
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
(adding Cc: tpm maintainers, after I had cut the Cc list earlier...)
Quoted 20 lines · Justin P. Mattock
Quoted 10 lines · Stefan Richter
Quoted 9 lines · Justin P. Mattock
Quoted 7 lines · Peter Stuge
Quoted 4 lines · Justin P. Mattock
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries
to really see why/what this is.Check out the tool cscope. (Or kscope, if you prefer a GUI.)
Quoted 8 lines
Quoted 2 lines
thanks for this tool.. I think this is what I need.. running around not knowing what/where the manual is for a call is a bit daunting.
Similar to cscope/kscope but online:
http://lxr.free-electrons.com/
http://lxr.linux.no/linux
Quoted 7 lines
hmm.. yeah I use those guys a lot.. with grep also.. I think what might throw me off is things like def.orig = def.new then def.orig gets lost in the
mix(or it's there, but the grep becomes gigantic in code results.)main thing I look for is googling "somedefinition linux man" for some idea of what that function does.Justin P. Mattock
I'm afraid that even if there was inline documentation of the function, it would still be near impossible to guess what to do with unused return codes if one is not familiar with the hardware and with the driver.
To quote your original patch again:
Quoted 19 lines
Im getting this warning when compiling:
CCdrivers/char/tpm/tpm.odrivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not usedThe below patch gets rid of the warning,
but I'm not sure if it's the best solution.Signed-off-by Justin P. Mattock <[email protected]>--- drivers/char/tpm/tpm.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/char/tpm/tpm.c +0
-0
drivers/char/tpm/tpm.c void tpm_gen_interrupt(struct tpm_chip *chip) · line 520
Quoted 7 lines
drivers/char/tpm/tpm.c +2
-0@@ -514,6 +514,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip) rc =transmit_cmd (chip, &tpm_cmd,TPM_INTERNAL_RESULT_SIZE ,"attempting to determine the timeouts" ); +if (!rc) + rc =0 ; }EXPORT_SYMBOL_GPL (tpm_gen_interrupt);
So, void tpm_gen_interrupt() itself clearly is not prepared to do anything about an error return from transmit_cmd. The question is, is this OK and can the "rc = " simply be removed, or should tpm_gen_interrupt gain some error handling, or should tpm_gen_interrupt be changed to a non-void function and its callers check for errors in tpm_gen_interrupt?
It could very well be that there is really no need or no possibility for error handling. But until somebody familiar with the matter has figured this out, it is in fact better to leave the compiler warning in place.
Just silencing the compiler if the possibility exists that there is an actual flaw here is not the way to go. Still, good that you reported it even with an RFC patch, since the authors were obviously unaware of such a warning until now.
Signature · 3 lines
Stefan Richter -=====-==-=- -==- -==== http://arcgraph.de/sr/
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
Quoted 57 lines · Stefan Richter
(adding Cc: tpm maintainers, after I had cut the Cc list earlier...)
Quoted 20 lines · Justin P. Mattock
Quoted 10 lines · Stefan Richter
Quoted 9 lines · Justin P. Mattock
Quoted 7 lines · Peter Stuge
Quoted 4 lines · Justin P. Mattock
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries
to really see why/what this is.Check out the tool cscope. (Or kscope, if you prefer a GUI.)
Quoted 8 lines
Quoted 2 lines
thanks for this tool.. I think this is what I need.. running around not knowing what/where the manual is for a call is a bit daunting.
Similar to cscope/kscope but online:
http://lxr.free-electrons.com/
http://lxr.linux.no/linuxQuoted 7 lines
hmm.. yeah I use those guys a lot.. with grep also.. I think what might throw me off is things like def.orig = def.new then def.orig gets lost in the
mix(or it's there, but the grep becomes gigantic in code results.)main thing I look for is googling "somedefinition linux man" for some idea of what that function does.Justin P. Mattock
I'm afraid that even if there was inline documentation of the function, it would still be near impossible to guess what to do with unused return codes if one is not familiar with the hardware and with the driver.
To quote your original patch again:
Quoted 20 lines
Im getting this warning when compiling:
CCdrivers/char/tpm/tpm.odrivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not usedThe below patch gets rid of the warning,
but I'm not sure if it's the best solution.Signed-off-by Justin P. Mattock<[email protected]>--- drivers/char/tpm/tpm.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/char/tpm/tpm.c +0
-0@@ -514,6 +514,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip)
Quoted 14 lines
drivers/char/tpm/tpm.c void tpm_gen_interrupt(struct tpm_chip *chip) · line 520
Quoted 6 lines
drivers/char/tpm/tpm.c +2
-0rc =transmit_cmd (chip,&tpm_cmd,TPM_INTERNAL_RESULT_SIZE ,"attempting to determine the timeouts" ); +if (!rc) + rc =0 ; }EXPORT_SYMBOL_GPL (tpm_gen_interrupt);So, void
tpm_gen_interrupt()itself clearly is not prepared to do anything about an error return fromtransmit_cmd. The question is, is this OK and can the "rc = " simply be removed, or shouldtpm_gen_interruptgain some error handling, or shouldtpm_gen_interruptbe changed to a non-void function and its callers check for errors intpm_gen_interrupt?
still not sure what that mechanism is doing..
I was going by the warning message i.g. set but not used
so as soon as it was being used even by adding printk, gcc was happy.
But shutting it off seemed a better approach why? because at the time I knew it would work, or fixed it temporarily until somebody who's code this is can look at it and send out a better solution(hence what you did).
Quoted 4 lines
It could very well be that there is really no need or no possibility for error handling. But until somebody familiar with the matter has figured this out, it is in fact better to leave the compiler warning in place.
yep.. I agree..
Quoted 4 lines
Just silencing the compiler if the possibility exists that there is an actual flaw here is not the way to go. Still, good that you reported it even with an RFC patch, since the authors were obviously unaware of such a warning until now.
I did not like the idea of silencing it.. due to the fact that it can be forgotten(or lost in the sands of time per-see) best I just file a bug report then..in these types of cases.
In any case I still have more warnings..(and that's just my .config)
who knows how many more there are.. If you guys like I can go ahead in the next few days and send out another set(minus the rc = 0; thing that I did) then go from there.
keep in mind I'm just tackling the ones I think are easy.. ones with double variables I left until later down the line..
Justin P. Mattock
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to Peter StugeQuoted 7 lines · Peter Stuge
Quoted 6 lines · Justin P. Mattock
Quoted 2 lines
*baffled* Why did you think that would work? transmit_cmd()s signature has 4 parameters.
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is.
Justin, I think you're on the wrong track here. You seem to be in a hurry to fix all these warnings generated by gcc 4.6. There is no hurry at all. Most warnings are false positives, and actual bugs may take some thinking and knowledge. So rushing is not needed and not desirable. Going too fast, you might even introduce new bugs, or prevent old bugs from being properly fixed.
Warnings are a chance to make the code better. The goal is not to fix them quickly, but to fix them properly. If this is not your intent, then please stop immediately and let others deal with these warnings. If you want to help, this is appreciated, but what we need it quality, not quantity.
Quoted 1 line
Check out the tool cscope. (Or kscope, if you prefer a GUI.)
Or just LXR online if you don't want to install anything:
http://lxr.linux.no/linux
http://lxr.linux.no/#linux+v2.6.34/drivers/char/tpm/tpm.c#L451
Signature · 1 line
Jean Delvare
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
Quoted 16 lines · Jean Delvare
Quoted 7 lines · Peter Stuge
Quoted 6 lines · Justin P. Mattock
Quoted 2 lines
*baffled* Why did you think that would work? transmit_cmd()s signature has 4 parameters.
I have no manual in front of me. Did a quick google, but came up with (no hits) info on what that function does. grep showed too many entries to really see why/what this is.
Justin, I think you're on the wrong track here. You seem to be in a hurry to fix all these warnings generated by gcc 4.6. There is no hurry at all. Most warnings are false positives, and actual bugs may take some thinking and knowledge. So rushing is not needed and not desirable. Going too fast, you might even introduce new bugs, or prevent old bugs from being properly fixed.
Quoted 6 lines
Warnings are a chance to make the code better. The goal is not to fix them quickly, but to fix them properly. If this is not your intent, then please stop immediately and let others deal with these warnings. If you want to help, this is appreciated, but what we need it quality, not quantity.
your right.. I do have this "must get it fixed now, or else cut your head of mentality".. causing me to rush through things.. who knows why I do this..(I dont know why I do this honestly)
Quoted 7 lines
Quoted 1 line
Check out the tool cscope. (Or kscope, if you prefer a GUI.)
Or just LXR online if you don't want to install anything:
http://lxr.linux.no/linux
http://lxr.linux.no/#linux+v2.6.34/drivers/char/tpm/tpm.c#L451
At this point though gentlemen/ladies I'm pretty much crapped out now!! so any answer is going to be skewed. but rushing through things is not good.
Justin P. Mattock
Re: [PATCH 7/8]ieee1394/sdp2 Fix warning: variable 'unit_characteristics' set but not used
In reply to Justin P. MattockQuoted 1 line · Justin P. Mattock
Temporary fix until something is resolved
This is wrong by design, sorry. Warnings aren't blocking, and thus need no "temporary fix". Such temporary fixes would be only hiding the warning, cancelling the good work of gcc developers. Nack nack nack.
Quoted 23 lines
to fix the below warning:
CC [M]drivers/ieee1394/sbp2.odrivers/ieee1394/sbp2.c: In function 'sbp2_parse_unit_directory':drivers/ieee1394/sbp2.c:1353:6: warning: variable 'unit_characteristics' set but not usedSigned-off-by Justin P. Mattock <[email protected]>--- drivers/ieee1394/sbp2.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/ieee1394/sbp2.c +2
-0@@ -1356,6 +1356,8 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu, management_agent_addr =0 ; unit_characteristics =0 ; +if (!unit_characteristics) + unit_characteristics =0 ; firmware_revision =SBP2_ROM_VALUE_MISSING ; model = ud->flags &UNIT_DIRECTORY_MODEL_ID ? ud->model_id :SBP2_ROM_VALUE_MISSING ;
Signature · 1 line
Jean Delvare
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to David DaneyHi David,
Quoted 44 lines · David Daney
Quoted 35 lines · Jean Delvare
Hi Justin,
Quoted 17 lines · Justin P. Mattock
could be a right solution, could be wrong
here is the warning:
CCdrivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +0
-0drivers/i2c/i2c-core.c static int i2c_register_adapter(struct i2c_adapter *adap) · line 798
Quoted 5 lines
drivers/i2c/i2c-core.c +2
-0@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;One word:
scripts/checkpatch.plIn other news, the above is just plain wrong. First we force people to read the result of
bus_for_each_drv()and then when they do and don't need the value, gcc complains, so we add one more layer of useless code, which developers and possibly tools will later wonder and complain about? I can easily imagine that a static code analyzer would spot the above code as being a potential bug.Quoted 7 lines
Let's stop this madness now please.
Either
__must_checkgoes away frombus_for_each_drv()and from every other function which raises this problem, or we must disable that new type of warning gcc 4.6.0 generates. Depends which warnings we value more, as we can't sanely have both.
Quoted 3 lines
That is the crux of the whole thing. Putting in crap to get rid of the
__must_checkwarning someone obviously wanted to provoke is just plain wrong.
__process_new_adapter() calls i2c_do_add_adapter() which always returns
0. Why should I check the return value of bus_for_each_drv() when I know it will always be 0 by construction?
Also note that the same function is also called through bus_for_each_dev() somewhere else in i2c-core, and there is no warning there because bus_for_each_dev() is not marked __must_check. How consistent is this? If bus_for_each_dev() is OK without __must_check, then I can't see why bus_for_each_drv() wouldn't be.
Quoted 9 lines
I don't know what the answer is, but in addition to your suggestion of removing the
__must_check, you might try:
BUG_ON(dummy != WHAT_IT_SHOULD_BE);or
if (dummy !=
WHAT_IT_SHOULD_BE)panic("nice message here);
Which will never trigger.
Quoted 11 lines
or
static inline void
i_really_know_what_i_am_doing(int arg){ /* * Trick the compiler because we don't want to * handle error conditions. */ return; }
Quoted 5 lines
..
..
..i_really_know_what_i_am_doing(dummy);
Which is adding a lot of lines, and might eventually fail when the compiler becomes smarter (if it isn't already). Thanks but no thanks. If I really have to chose one of these evils, I'll go for BUG_ON(), at least the intent is clear and the bloat is minimum.
Signature · 1 line
Jean Delvare
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to Justin P. MattockHi Justin,
Quoted 29 lines · Justin P. Mattock
Quoted 15 lines · Jean Delvare
Hi Justin,
Quoted 12 lines · Justin P. Mattock
could be a right solution, could be wrong
here is the warning:
CCdrivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)Quoted 12 lines
drivers/i2c/i2c-core.c static int i2c_register_adapter(struct i2c_adapter *adap) · line 798
Quoted 10 lines
drivers/i2c/i2c-core.c +2
-0@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;One word:
scripts/checkpatch.pl
Quoted 2 lines
it was this, and/or just take the code out
(since I'm a newbie)
I was not (yet) arguing on the code itself, but on its format. Any patch you send should pass the formatting tests performed by scripts/checkpatch.pl. Thanks.
Signature · 1 line
Jean Delvare
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to Jean DelvareQuoted 55 lines · Jean Delvare
Hi David,
Quoted 44 lines · David Daney
Quoted 35 lines · Jean Delvare
Hi Justin,
Quoted 17 lines · Justin P. Mattock
could be a right solution, could be wrong
here is the warning:
CCdrivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +0
-0drivers/i2c/i2c-core.c static int i2c_register_adapter(struct i2c_adapter *adap) · line 798
Quoted 5 lines
drivers/i2c/i2c-core.c +2
-0@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;One word:
scripts/checkpatch.plIn other news, the above is just plain wrong. First we force people to read the result of
bus_for_each_drv()and then when they do and don't need the value, gcc complains, so we add one more layer of useless code, which developers and possibly tools will later wonder and complain about? I can easily imagine that a static code analyzer would spot the above code as being a potential bug.Quoted 7 lines
Let's stop this madness now please.
Either
__must_checkgoes away frombus_for_each_drv()and from every other function which raises this problem, or we must disable that new type of warning gcc 4.6.0 generates. Depends which warnings we value more, as we can't sanely have both.Quoted 3 lines
That is the crux of the whole thing. Putting in crap to get rid of the
__must_checkwarning someone obviously wanted to provoke is just plain wrong.
__process_new_adapter()callsi2c_do_add_adapter()which always returns
0. Why should I check the return value ofbus_for_each_drv()when I know it will always be 0 by construction?
Quoted 6 lines
Also note that the same function is also called through
bus_for_each_dev()somewhere else in i2c-core, and there is no warning there becausebus_for_each_dev()is not marked__must_check. How consistent is this? Ifbus_for_each_dev()is OK without__must_check, then I can't see whybus_for_each_drv()wouldn't be.
Well, I would advocate removing the __must_check then.
David Daney
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to Jean DelvareQuoted 32 lines · Jean Delvare
Hi Justin,
Quoted 29 lines · Justin P. Mattock
Quoted 27 lines · Jean Delvare
Hi Justin,
Quoted 17 lines · Justin P. Mattock
could be a right solution, could be wrong
here is the warning:
CCdrivers/i2c/i2c-core.odrivers/i2c/i2c-core.c: In function 'i2c_register_adapter':drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/i2c/i2c-core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +0
-0drivers/i2c/i2c-core.c static int i2c_register_adapter(struct i2c_adapter *adap) · line 798
Quoted 5 lines
drivers/i2c/i2c-core.c +2
-0@@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)mutex_lock (&core_lock); dummy =bus_for_each_drv (&i2c_bus_type,NULL , adap, __process_new_adapter); +if (!dummy) + dummy =0 ;One word:
scripts/checkpatch.pl
Quoted 7 lines
Quoted 2 lines
it was this, and/or just take the code out
(since I'm a newbie)I was not (yet) arguing on the code itself, but on its format. Any patch you send should pass the formatting tests performed by
scripts/checkpatch.pl. Thanks.
o.k. I'll make sure I run everything through checkpatch.pl before sending anything.
Justin P. Mattock
Re: [PATCH 7/8]ieee1394/sdp2 Fix warning: variable 'unit_characteristics' set but not used
In reply to Jean DelvareQuoted 7 lines · Jean Delvare
Quoted 1 line · Justin P. Mattock
Temporary fix until something is resolved
This is wrong by design, sorry. Warnings aren't blocking, and thus need no "temporary fix". Such temporary fixes would be only hiding the warning, cancelling the good work of gcc developers. Nack nack nack.
o.k.
Quoted 16 lines
Quoted 16 lines
to fix the below warning:
CC [M] drivers/ieee1394/sbp2.o
drivers/ieee1394/sbp2.c: In function 'sbp2_parse_unit_directory':drivers/ieee1394/sbp2.c:1353:6: warning: variable 'unit_characteristics' set but not usedSigned-off-by Justin P. Mattock<[email protected]>--- drivers/ieee1394/sbp2.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/ieee1394/sbp2.c +0
-0@@ -1356,6 +1356,8 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
Quoted 9 lines
drivers/ieee1394/sbp2.c static void sbp2_parse_unit_directory(struct sbp2_lu *lu, · line 1363
Quoted 7 lines
drivers/ieee1394/sbp2.c +2
-0management_agent_addr =0 ; unit_characteristics =0 ; +if (!unit_characteristics) + unit_characteristics =0 ; firmware_revision =SBP2_ROM_VALUE_MISSING ; model = ud->flags&UNIT_DIRECTORY_MODEL_ID ? ud->model_id :SBP2_ROM_VALUE_MISSING ;
Thanks for the response and info on this.
Justin P. Mattock
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
In reply to Justin P. MattockQuoted 30 lines · On Tuesday 15 of June 2010 00:26:44 Justin P. Mattock wrote:
Im getting this warning when compiling:
CCdrivers/char/tpm/tpm.odrivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not usedThe below patch gets rid of the warning,
but I'm not sure if it's the best solution.Signed-off-by Justin P. Mattock <[email protected]>--- drivers/char/tpm/tpm.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/char/tpm/tpm.c +2
-0@@ -514,6 +514,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip) rc =transmit_cmd (chip, &tpm_cmd,TPM_INTERNAL_RESULT_SIZE ,"attempting to determine the timeouts" ); +if (!rc) + rc =0 ; }EXPORT_SYMBOL_GPL (tpm_gen_interrupt);Signature · 1 line
1.7.1.rc1.21.gf3bd6
Hi Justin
IMHO
See code of functions tpm_transmit(), transmit_cmd and tpm_gen_interrupt(). In tpm_gen_interrupt() not need check rc for wrong value bacause if in function transmit_cmd() len == TPM_ERROR_SIZE then put a debug message (dev_dbg()). Again, if something wrong in tpm_transmit() then runs dev_err() and rc in tpm_gen_interrupt() get -E* value.
So, we can remove unused rc variable in tpm_gen_interrupt().
See patch below. Note: I not tested it.
Subject: [PATCH] drivers: tpm.c: Remove unused variable 'rc'
--- drivers/char/tpm/tpm.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm.c +0 -0
@@ -505,15 +505,14 @@ ssize_t tpm_getcap(struct device *dev, __be32 subcap_id,
cap_t *cap,
void tpm_gen_interrupt(struct tpm_chip *chip)
{
struct tpm_cmd_t tpm_cmd;
- ssize_t rc;
tpm_cmd.header.in = tpm_getcap_header; tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
- rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
- "attempting to determine the timeouts");
+ transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
+ "attempting to determine the timeouts");
}
EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
Signature · 1 line
1.7.1
Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but not used
Quoted 64 lines · Sergey V.
Quoted 28 lines · On Tuesday 15 of June 2010 00:26:44 Justin P. Mattock wrote:
Im getting this warning when compiling:
CCdrivers/char/tpm/tpm.odrivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not usedThe below patch gets rid of the warning,
but I'm not sure if it's the best solution.Signed-off-by Justin P. Mattock<[email protected]>--- drivers/char/tpm/tpm.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/char/tpm/tpm.c +2
-1@@ -514,6 +514,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip) rc =transmit_cmd (chip,&tpm_cmd,TPM_INTERNAL_RESULT_SIZE ,"attempting to determine the timeouts" ); +if (!rc) + rc =0 ; }EXPORT_SYMBOL_GPL (tpm_gen_interrupt); --Quoted 2 lines
1.7.1.rc1.21.gf3bd6
Hi Justin
IMHO
See code of functionstpm_transmit(),transmit_cmdandtpm_gen_interrupt(). Intpm_gen_interrupt()not need check rc for wrong value bacause if in functiontransmit_cmd()len ==TPM_ERROR_SIZEthen put a debug message (dev_dbg()). Again, if something wrong intpm_transmit()then runsdev_err()and rc intpm_gen_interrupt()get -E* value.
So, we can remove unused rc variable intpm_gen_interrupt().See patch below. Note: I not tested it.
Subject: [PATCH] drivers:
tpm.c: Remove unused variable 'rc'--- drivers/char/tpm/tpm.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)drivers/char/tpm/tpm.c +0
-1@@ -505,15 +505,14 @@ ssize_t tpm_getcap(struct device *dev, __be32 subcap_id,cap_t *cap, void tpm_gen_interrupt(struct tpm_chip *chip) { struct tpm_cmd_t tpm_cmd; -ssize_t rc; tpm_cmd.header.in = tpm_getcap_header;
drivers/char/tpm/tpm.c ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, · line 518
Quoted 10 lines
drivers/char/tpm/tpm.c +2
-2tpm_cmd.params.getcap_in.cap =TPM_CAP_PROP ; tpm_cmd.params.getcap_in.subcap_size =cpu_to_be32 (4 ); tpm_cmd.params.getcap_in.subcap =TPM_CAP_PROP_TIS_TIMEOUT ; - rc =transmit_cmd (chip,&tpm_cmd,TPM_INTERNAL_RESULT_SIZE , -"attempting to determine the timeouts" ); +transmit_cmd (chip,&tpm_cmd,TPM_INTERNAL_RESULT_SIZE , +"attempting to determine the timeouts" ); }EXPORT_SYMBOL_GPL (tpm_gen_interrupt);
o.k. applied this patch and rebuilt, here is what I see:
CC [M] drivers/char/ipmi/ipmi_poweroff.o CC drivers/char/tpm/tpm.o CC drivers/char/tpm/tpm_bios.o CC drivers/char/tpm/tpm_tis.o LD drivers/char/tpm/built-in.o
looks good over here Thanks for sending this..
Justin P. Mattock
Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
In reply to David DaneyQuoted 5 lines · David Daney
Quoted 4 lines · Jean Delvare
__process_new_adapter()callsi2c_do_add_adapter()which always returns
0. Why should I check the return value ofbus_for_each_drv()when I know it will always be 0 by construction?
Quoted 7 lines
Quoted 5 lines
Also note that the same function is also called through
bus_for_each_dev()somewhere else in i2c-core, and there is no warning there becausebus_for_each_dev()is not marked__must_check. How consistent is this? Ifbus_for_each_dev()is OK without__must_check, then I can't see whybus_for_each_drv()wouldn't be.Well, I would advocate removing the
__must_checkthen.
I have just sent a patch to LKML doing exactly this.
Signature · 1 line
Jean Delvare