* [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS
@ 2011-04-11 21:50 maksim.rayskiy
2011-04-11 22:08 ` Mike Frysinger
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: maksim.rayskiy @ 2011-04-11 21:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Maksim Rayskiy
From: Maksim Rayskiy <maksim.rayskiy@gmail.com>
When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
gcc-4.5.2 generates a slew of "warning: statement with no effect"
on references to non-void functions defined as 0.
To avoid these warnings, change appropriate definitions from
#define dbg_xxx(a) 0
to
#define dbg_xxx(a) ({0; })
Signed-off-by: Maksim Rayskiy <maksim.rayskiy@gmail.com>
---
fs/ubifs/debug.h | 50 +++++++++++++++++++++++++-------------------------
1 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index 919f0de..e30a629 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -425,34 +425,34 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c);
#define dbg_dump_index(c) ({})
#define dbg_dump_lpt_lebs(c) ({})
-#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0
-#define dbg_old_index_check_init(c, zroot) 0
+#define dbg_walk_index(c, leaf_cb, znode_cb, priv) ({0; })
+#define dbg_old_index_check_init(c, zroot) ({0; })
#define dbg_save_space_info(c) ({})
-#define dbg_check_space_info(c) 0
-#define dbg_check_old_index(c, zroot) 0
-#define dbg_check_cats(c) 0
-#define dbg_check_ltab(c) 0
-#define dbg_chk_lpt_free_spc(c) 0
-#define dbg_chk_lpt_sz(c, action, len) 0
-#define dbg_check_synced_i_size(inode) 0
-#define dbg_check_dir_size(c, dir) 0
-#define dbg_check_tnc(c, x) 0
-#define dbg_check_idx_size(c, idx_size) 0
-#define dbg_check_filesystem(c) 0
+#define dbg_check_space_info(c) ({0; })
+#define dbg_check_old_index(c, zroot) ({0; })
+#define dbg_check_cats(c) ({0; })
+#define dbg_check_ltab(c) ({0; })
+#define dbg_chk_lpt_free_spc(c) ({0; })
+#define dbg_chk_lpt_sz(c, action, len) ({0; })
+#define dbg_check_synced_i_size(inode) ({0; })
+#define dbg_check_dir_size(c, dir) ({0; })
+#define dbg_check_tnc(c, x) ({0; })
+#define dbg_check_idx_size(c, idx_size) ({0; })
+#define dbg_check_filesystem(c) ({0; })
#define dbg_check_heap(c, heap, cat, add_pos) ({})
-#define dbg_check_lprops(c) 0
-#define dbg_check_lpt_nodes(c, cnode, row, col) 0
-#define dbg_check_inode_size(c, inode, size) 0
-#define dbg_check_data_nodes_order(c, head) 0
-#define dbg_check_nondata_nodes_order(c, head) 0
-#define dbg_force_in_the_gaps_enabled 0
-#define dbg_force_in_the_gaps() 0
-#define dbg_failure_mode 0
-
-#define dbg_debugfs_init() 0
+#define dbg_check_lprops(c) ({0; })
+#define dbg_check_lpt_nodes(c, cnode, row, col) ({0; })
+#define dbg_check_inode_size(c, inode, size) ({0; })
+#define dbg_check_data_nodes_order(c, head) ({0; })
+#define dbg_check_nondata_nodes_order(c, head) ({0; })
+#define dbg_force_in_the_gaps_enabled ({0; })
+#define dbg_force_in_the_gaps() ({0; })
+#define dbg_failure_mode ({0; })
+
+#define dbg_debugfs_init() ({0; })
#define dbg_debugfs_exit()
-#define dbg_debugfs_init_fs(c) 0
-#define dbg_debugfs_exit_fs(c) 0
+#define dbg_debugfs_init_fs(c) ({0; })
+#define dbg_debugfs_exit_fs(c) ({0; })
#endif /* !CONFIG_UBIFS_FS_DEBUG */
#endif /* !__UBIFS_DEBUG_H__ */
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS
2011-04-11 21:50 [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS maksim.rayskiy
@ 2011-04-11 22:08 ` Mike Frysinger
2011-04-11 22:36 ` Maksim Rayskiy
2011-04-12 0:12 ` Russ Dill
2011-04-12 8:25 ` Artem Bityutskiy
2 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2011-04-11 22:08 UTC (permalink / raw)
To: maksim.rayskiy; +Cc: linux-mtd
On Mon, Apr 11, 2011 at 17:50, <maksim.rayskiy@gmail.com> wrote:
> From: Maksim Rayskiy <maksim.rayskiy@gmail.com>
>
> When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
> gcc-4.5.2 generates a slew of "warning: statement with no effect"
> on references to non-void functions defined as 0.
> To avoid these warnings, change appropriate definitions from
> #define dbg_xxx(a) 0
> to
> #define dbg_xxx(a) ({0; })
we probably want to make these inline funcs. otherwise we get
misbehavior if someone does something like:
dbg_dump_index(c++);
-mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS
2011-04-11 22:08 ` Mike Frysinger
@ 2011-04-11 22:36 ` Maksim Rayskiy
2011-04-12 0:49 ` Mike Frysinger
0 siblings, 1 reply; 7+ messages in thread
From: Maksim Rayskiy @ 2011-04-11 22:36 UTC (permalink / raw)
To: Mike Frysinger; +Cc: linux-mtd
On Mon, Apr 11, 2011 at 3:08 PM, Mike Frysinger <vapier.adi@gmail.com> wrote:
> On Mon, Apr 11, 2011 at 17:50, <maksim.rayskiy@gmail.com> wrote:
>> From: Maksim Rayskiy <maksim.rayskiy@gmail.com>
>>
>> When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
>> gcc-4.5.2 generates a slew of "warning: statement with no effect"
>> on references to non-void functions defined as 0.
>> To avoid these warnings, change appropriate definitions from
>> #define dbg_xxx(a) 0
>> to
>> #define dbg_xxx(a) ({0; })
>
> we probably want to make these inline funcs. otherwise we get
> misbehavior if someone does something like:
> dbg_dump_index(c++);
> -mike
>
I agree that would be a problem, but if such calls existed, we would
be dealing not with compiler warnings but with completely broken code.
I think it is bad style to have side-effects in debug functions.
Thanks,
Maksim.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS
2011-04-11 21:50 [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS maksim.rayskiy
2011-04-11 22:08 ` Mike Frysinger
@ 2011-04-12 0:12 ` Russ Dill
2011-04-12 0:27 ` Russ Dill
2011-04-12 8:25 ` Artem Bityutskiy
2 siblings, 1 reply; 7+ messages in thread
From: Russ Dill @ 2011-04-12 0:12 UTC (permalink / raw)
To: maksim.rayskiy; +Cc: linux-mtd
On Mon, Apr 11, 2011 at 2:50 PM, <maksim.rayskiy@gmail.com> wrote:
> From: Maksim Rayskiy <maksim.rayskiy@gmail.com>
>
> When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
> gcc-4.5.2 generates a slew of "warning: statement with no effect"
> on references to non-void functions defined as 0.
> To avoid these warnings, change appropriate definitions from
> #define dbg_xxx(a) 0
> to
> #define dbg_xxx(a) ({0; })
>
> Signed-off-by: Maksim Rayskiy <maksim.rayskiy@gmail.com>
> ---
> fs/ubifs/debug.h | 50 +++++++++++++++++++++++++-------------------------
> 1 files changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
> index 919f0de..e30a629 100644
> --- a/fs/ubifs/debug.h
> +++ b/fs/ubifs/debug.h
> @@ -425,34 +425,34 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c);
> #define dbg_dump_index(c) ({})
> #define dbg_dump_lpt_lebs(c) ({})
>
> -#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0
> -#define dbg_old_index_check_init(c, zroot) 0
> +#define dbg_walk_index(c, leaf_cb, znode_cb, priv) ({0; })
> +#define dbg_old_index_check_init(c, zroot) ({0; })
> #define dbg_save_space_info(c) ({})
> -#define dbg_check_space_info(c) 0
> -#define dbg_check_old_index(c, zroot) 0
> -#define dbg_check_cats(c) 0
> -#define dbg_check_ltab(c) 0
> -#define dbg_chk_lpt_free_spc(c) 0
> -#define dbg_chk_lpt_sz(c, action, len) 0
> -#define dbg_check_synced_i_size(inode) 0
> -#define dbg_check_dir_size(c, dir) 0
> -#define dbg_check_tnc(c, x) 0
> -#define dbg_check_idx_size(c, idx_size) 0
> -#define dbg_check_filesystem(c) 0
> +#define dbg_check_space_info(c) ({0; })
> +#define dbg_check_old_index(c, zroot) ({0; })
> +#define dbg_check_cats(c) ({0; })
> +#define dbg_check_ltab(c) ({0; })
> +#define dbg_chk_lpt_free_spc(c) ({0; })
> +#define dbg_chk_lpt_sz(c, action, len) ({0; })
> +#define dbg_check_synced_i_size(inode) ({0; })
> +#define dbg_check_dir_size(c, dir) ({0; })
> +#define dbg_check_tnc(c, x) ({0; })
> +#define dbg_check_idx_size(c, idx_size) ({0; })
> +#define dbg_check_filesystem(c) ({0; })
> #define dbg_check_heap(c, heap, cat, add_pos) ({})
> -#define dbg_check_lprops(c) 0
> -#define dbg_check_lpt_nodes(c, cnode, row, col) 0
> -#define dbg_check_inode_size(c, inode, size) 0
> -#define dbg_check_data_nodes_order(c, head) 0
> -#define dbg_check_nondata_nodes_order(c, head) 0
> -#define dbg_force_in_the_gaps_enabled 0
> -#define dbg_force_in_the_gaps() 0
> -#define dbg_failure_mode 0
> -
> -#define dbg_debugfs_init() 0
> +#define dbg_check_lprops(c) ({0; })
> +#define dbg_check_lpt_nodes(c, cnode, row, col) ({0; })
> +#define dbg_check_inode_size(c, inode, size) ({0; })
> +#define dbg_check_data_nodes_order(c, head) ({0; })
> +#define dbg_check_nondata_nodes_order(c, head) ({0; })
> +#define dbg_force_in_the_gaps_enabled ({0; })
> +#define dbg_force_in_the_gaps() ({0; })
> +#define dbg_failure_mode ({0; })
> +
> +#define dbg_debugfs_init() ({0; })
> #define dbg_debugfs_exit()
> -#define dbg_debugfs_init_fs(c) 0
> -#define dbg_debugfs_exit_fs(c) 0
> +#define dbg_debugfs_init_fs(c) ({0; })
> +#define dbg_debugfs_exit_fs(c) ({0; })
>
> #endif /* !CONFIG_UBIFS_FS_DEBUG */
> #endif /* !__UBIFS_DEBUG_H__ */
> --
> 1.7.1
>
Should these all just be:
do {} while(0)
Stuff like:
#define dbg_debugfs_exit()
looks particularly dangerous.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS
2011-04-12 0:12 ` Russ Dill
@ 2011-04-12 0:27 ` Russ Dill
0 siblings, 0 replies; 7+ messages in thread
From: Russ Dill @ 2011-04-12 0:27 UTC (permalink / raw)
To: maksim.rayskiy; +Cc: linux-mtd
On Mon, Apr 11, 2011 at 5:12 PM, Russ Dill <russ.dill@gmail.com> wrote:
> On Mon, Apr 11, 2011 at 2:50 PM, <maksim.rayskiy@gmail.com> wrote:
>> From: Maksim Rayskiy <maksim.rayskiy@gmail.com>
>>
>> When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
>> gcc-4.5.2 generates a slew of "warning: statement with no effect"
>> on references to non-void functions defined as 0.
>> To avoid these warnings, change appropriate definitions from
>> #define dbg_xxx(a) 0
>> to
>> #define dbg_xxx(a) ({0; })
>>
>> Signed-off-by: Maksim Rayskiy <maksim.rayskiy@gmail.com>
>> ---
>> fs/ubifs/debug.h | 50 +++++++++++++++++++++++++-------------------------
>> 1 files changed, 25 insertions(+), 25 deletions(-)
>>
>> diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
>> index 919f0de..e30a629 100644
>> --- a/fs/ubifs/debug.h
>> +++ b/fs/ubifs/debug.h
>> @@ -425,34 +425,34 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c);
>> #define dbg_dump_index(c) ({})
>> #define dbg_dump_lpt_lebs(c) ({})
>>
>> -#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0
>> -#define dbg_old_index_check_init(c, zroot) 0
>> +#define dbg_walk_index(c, leaf_cb, znode_cb, priv) ({0; })
>> +#define dbg_old_index_check_init(c, zroot) ({0; })
>> #define dbg_save_space_info(c) ({})
>> -#define dbg_check_space_info(c) 0
>> -#define dbg_check_old_index(c, zroot) 0
>> -#define dbg_check_cats(c) 0
>> -#define dbg_check_ltab(c) 0
>> -#define dbg_chk_lpt_free_spc(c) 0
>> -#define dbg_chk_lpt_sz(c, action, len) 0
>> -#define dbg_check_synced_i_size(inode) 0
>> -#define dbg_check_dir_size(c, dir) 0
>> -#define dbg_check_tnc(c, x) 0
>> -#define dbg_check_idx_size(c, idx_size) 0
>> -#define dbg_check_filesystem(c) 0
>> +#define dbg_check_space_info(c) ({0; })
>> +#define dbg_check_old_index(c, zroot) ({0; })
>> +#define dbg_check_cats(c) ({0; })
>> +#define dbg_check_ltab(c) ({0; })
>> +#define dbg_chk_lpt_free_spc(c) ({0; })
>> +#define dbg_chk_lpt_sz(c, action, len) ({0; })
>> +#define dbg_check_synced_i_size(inode) ({0; })
>> +#define dbg_check_dir_size(c, dir) ({0; })
>> +#define dbg_check_tnc(c, x) ({0; })
>> +#define dbg_check_idx_size(c, idx_size) ({0; })
>> +#define dbg_check_filesystem(c) ({0; })
>> #define dbg_check_heap(c, heap, cat, add_pos) ({})
>> -#define dbg_check_lprops(c) 0
>> -#define dbg_check_lpt_nodes(c, cnode, row, col) 0
>> -#define dbg_check_inode_size(c, inode, size) 0
>> -#define dbg_check_data_nodes_order(c, head) 0
>> -#define dbg_check_nondata_nodes_order(c, head) 0
>> -#define dbg_force_in_the_gaps_enabled 0
>> -#define dbg_force_in_the_gaps() 0
>> -#define dbg_failure_mode 0
>> -
>> -#define dbg_debugfs_init() 0
>> +#define dbg_check_lprops(c) ({0; })
>> +#define dbg_check_lpt_nodes(c, cnode, row, col) ({0; })
>> +#define dbg_check_inode_size(c, inode, size) ({0; })
>> +#define dbg_check_data_nodes_order(c, head) ({0; })
>> +#define dbg_check_nondata_nodes_order(c, head) ({0; })
>> +#define dbg_force_in_the_gaps_enabled ({0; })
>> +#define dbg_force_in_the_gaps() ({0; })
>> +#define dbg_failure_mode ({0; })
>> +
>> +#define dbg_debugfs_init() ({0; })
>> #define dbg_debugfs_exit()
>> -#define dbg_debugfs_init_fs(c) 0
>> -#define dbg_debugfs_exit_fs(c) 0
>> +#define dbg_debugfs_init_fs(c) ({0; })
>> +#define dbg_debugfs_exit_fs(c) ({0; })
>>
>> #endif /* !CONFIG_UBIFS_FS_DEBUG */
>> #endif /* !__UBIFS_DEBUG_H__ */
>> --
>> 1.7.1
>>
>
> Should these all just be:
>
> do {} while(0)
never-mind, I see while the ({0;}) format is preferable.
> Stuff like:
>
> #define dbg_debugfs_exit()
>
> looks particularly dangerous.
but this still stands
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS
2011-04-11 22:36 ` Maksim Rayskiy
@ 2011-04-12 0:49 ` Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-04-12 0:49 UTC (permalink / raw)
To: Maksim Rayskiy; +Cc: linux-mtd
On Mon, Apr 11, 2011 at 18:36, Maksim Rayskiy wrote:
> On Mon, Apr 11, 2011 at 3:08 PM, Mike Frysinger wrote:
>> On Mon, Apr 11, 2011 at 17:50, <maksim.rayskiy@gmail.com> wrote:
>>> From: Maksim Rayskiy <maksim.rayskiy@gmail.com>
>>>
>>> When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
>>> gcc-4.5.2 generates a slew of "warning: statement with no effect"
>>> on references to non-void functions defined as 0.
>>> To avoid these warnings, change appropriate definitions from
>>> #define dbg_xxx(a) 0
>>> to
>>> #define dbg_xxx(a) ({0; })
>>
>> we probably want to make these inline funcs. otherwise we get
>> misbehavior if someone does something like:
>> dbg_dump_index(c++);
>
> I agree that would be a problem, but if such calls existed, we would
> be dealing not with compiler warnings but with completely broken code.
> I think it is bad style to have side-effects in debug functions.
we are dealing with broken code. people should not have to know about
the implementation of functions in order to safely use them.
-mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS
2011-04-11 21:50 [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS maksim.rayskiy
2011-04-11 22:08 ` Mike Frysinger
2011-04-12 0:12 ` Russ Dill
@ 2011-04-12 8:25 ` Artem Bityutskiy
2 siblings, 0 replies; 7+ messages in thread
From: Artem Bityutskiy @ 2011-04-12 8:25 UTC (permalink / raw)
To: maksim.rayskiy; +Cc: linux-mtd
On Mon, 2011-04-11 at 14:50 -0700, maksim.rayskiy@gmail.com wrote:
> From: Maksim Rayskiy <maksim.rayskiy@gmail.com>
>
> When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
> gcc-4.5.2 generates a slew of "warning: statement with no effect"
> on references to non-void functions defined as 0.
> To avoid these warnings, change appropriate definitions from
> #define dbg_xxx(a) 0
> to
> #define dbg_xxx(a) ({0; })
Hi, thanks for the fix, but I agree that something like
static inline int dbg_xxx(a) { return 0; }
would be cleaner. Would you mind trying that approach and sending a
patch?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-04-12 8:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-11 21:50 [PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS maksim.rayskiy
2011-04-11 22:08 ` Mike Frysinger
2011-04-11 22:36 ` Maksim Rayskiy
2011-04-12 0:49 ` Mike Frysinger
2011-04-12 0:12 ` Russ Dill
2011-04-12 0:27 ` Russ Dill
2011-04-12 8:25 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).