* [PATCH] fs: ocfs2: dir.c: Cleaning up uninitialized variables
@ 2014-06-01 13:53 Rickard Strandqvist
2014-06-02 18:44 ` Srinivas Eeda
2014-06-02 20:22 ` Andrew Morton
0 siblings, 2 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 13:53 UTC (permalink / raw)
To: Mark Fasheh, Joel Becker; +Cc: Rickard Strandqvist, ocfs2-devel, linux-kernel
There is a risk that the variable will be used without being initialized.
This was largely found by using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
fs/ocfs2/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 0717662..27aa4a1 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -3738,7 +3738,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
int credits, ret, i, num_used, did_quota = 0;
u32 cpos, split_hash, insert_hash = hinfo->major_hash;
u64 orig_leaves_start;
- int num_dx_leaves;
+ int num_dx_leaves = 0;
struct buffer_head **orig_dx_leaves = NULL;
struct buffer_head **new_dx_leaves = NULL;
struct ocfs2_alloc_context *data_ac = NULL, *meta_ac = NULL;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: ocfs2: dir.c: Cleaning up uninitialized variables
2014-06-01 13:53 [PATCH] fs: ocfs2: dir.c: Cleaning up uninitialized variables Rickard Strandqvist
@ 2014-06-02 18:44 ` Srinivas Eeda
2014-06-02 20:22 ` Andrew Morton
1 sibling, 0 replies; 4+ messages in thread
From: Srinivas Eeda @ 2014-06-02 18:44 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Mark Fasheh, Joel Becker, ocfs2-devel, linux-kernel, akpm
Acked-by: Srinivas Eeda <srinivas.eeda@oracle.com>
On 06/01/2014 06:53 AM, Rickard Strandqvist wrote:
> There is a risk that the variable will be used without being initialized.
>
> This was largely found by using a static code analysis program called cppcheck.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> fs/ocfs2/dir.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> index 0717662..27aa4a1 100644
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -3738,7 +3738,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
> int credits, ret, i, num_used, did_quota = 0;
> u32 cpos, split_hash, insert_hash = hinfo->major_hash;
> u64 orig_leaves_start;
> - int num_dx_leaves;
> + int num_dx_leaves = 0;
> struct buffer_head **orig_dx_leaves = NULL;
> struct buffer_head **new_dx_leaves = NULL;
> struct ocfs2_alloc_context *data_ac = NULL, *meta_ac = NULL;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: ocfs2: dir.c: Cleaning up uninitialized variables
2014-06-01 13:53 [PATCH] fs: ocfs2: dir.c: Cleaning up uninitialized variables Rickard Strandqvist
2014-06-02 18:44 ` Srinivas Eeda
@ 2014-06-02 20:22 ` Andrew Morton
2014-06-02 22:03 ` Rickard Strandqvist
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2014-06-02 20:22 UTC (permalink / raw)
To: Rickard Strandqvist; +Cc: Mark Fasheh, Joel Becker, ocfs2-devel, linux-kernel
On Sun, 1 Jun 2014 15:53:04 +0200 Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> wrote:
> There is a risk that the variable will be used without being initialized.
um, no there isn't.
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -3738,7 +3738,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
> int credits, ret, i, num_used, did_quota = 0;
> u32 cpos, split_hash, insert_hash = hinfo->major_hash;
> u64 orig_leaves_start;
> - int num_dx_leaves;
> + int num_dx_leaves = 0;
> struct buffer_head **orig_dx_leaves = NULL;
> struct buffer_head **new_dx_leaves = NULL;
> struct ocfs2_alloc_context *data_ac = NULL, *meta_ac = NULL;
If ocfs2_dx_dir_kmalloc_leaves() returns non-zero, num_dx_leaves will
have been initialized.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: ocfs2: dir.c: Cleaning up uninitialized variables
2014-06-02 20:22 ` Andrew Morton
@ 2014-06-02 22:03 ` Rickard Strandqvist
0 siblings, 0 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-06-02 22:03 UTC (permalink / raw)
To: Andrew Morton; +Cc: Mark Fasheh, Joel Becker, ocfs2-devel, linux-kernel
Hi
Yes, but if() above, there may be a:
goto out;
Or if kcalloc() fails in ocfs2_dx_dir_kmalloc_leaves() the variable
num_dx_leaves will not be set to any value.
But now that I look more carefully at it, I see that in the cases
orig_dx_leaves and new_dx_leaves ar NULL, so nothing will happen in
the out: part of the code.
Sorry about this :-(
Best regards
Rickard Strandqvist
2014-06-02 22:22 GMT+02:00 Andrew Morton <akpm@linux-foundation.org>:
> On Sun, 1 Jun 2014 15:53:04 +0200 Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> wrote:
>
>> There is a risk that the variable will be used without being initialized.
>
> um, no there isn't.
>
>> --- a/fs/ocfs2/dir.c
>> +++ b/fs/ocfs2/dir.c
>> @@ -3738,7 +3738,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
>> int credits, ret, i, num_used, did_quota = 0;
>> u32 cpos, split_hash, insert_hash = hinfo->major_hash;
>> u64 orig_leaves_start;
>> - int num_dx_leaves;
>> + int num_dx_leaves = 0;
>> struct buffer_head **orig_dx_leaves = NULL;
>> struct buffer_head **new_dx_leaves = NULL;
>> struct ocfs2_alloc_context *data_ac = NULL, *meta_ac = NULL;
>
> If ocfs2_dx_dir_kmalloc_leaves() returns non-zero, num_dx_leaves will
> have been initialized.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-02 22:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 13:53 [PATCH] fs: ocfs2: dir.c: Cleaning up uninitialized variables Rickard Strandqvist
2014-06-02 18:44 ` Srinivas Eeda
2014-06-02 20:22 ` Andrew Morton
2014-06-02 22:03 ` Rickard Strandqvist
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).