All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/4] linux/time.h: Remove dead code
@ 2017-10-06 13:04 Marek Behún
  2017-10-06 13:04 ` [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables Marek Behún
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Marek Behún @ 2017-10-06 13:04 UTC (permalink / raw)
  To: u-boot

Since
  rem = ((long) *tim_p) % SECSPERDAY;
the second while cycle
  while (rem >= SECSPERDAY)
is dead.

Reported-by: Coverity (CID: 167334)
Signed-off-by: Marek Behun <marek.behun@nic.cz>
---
 include/linux/time.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index bf12b99d37..b8d298eb4d 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -93,11 +93,6 @@ _DEFUN (localtime_r, (tim_p, res),
 	rem += SECSPERDAY;
 	--days;
     }
-    while (rem >= SECSPERDAY)
-    {
-	rem -= SECSPERDAY;
-	++days;
-    }
 
     /* compute hour, min, and sec */
     res->tm_hour = (int) (rem / SECSPERHOUR);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables
  2017-10-06 13:04 [U-Boot] [PATCH 1/4] linux/time.h: Remove dead code Marek Behún
@ 2017-10-06 13:04 ` Marek Behún
       [not found]   ` <99f56d19-544c-4604-4f82-bd7a9a1e45b6@comcast.net>
  2017-10-17  0:47   ` [U-Boot] [U-Boot, " Tom Rini
  2017-10-06 13:04 ` [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier Marek Behún
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 10+ messages in thread
From: Marek Behún @ 2017-10-06 13:04 UTC (permalink / raw)
  To: u-boot

The variable res should be initialized to 0 in these functions,
because if the searched key is not found, the variable is used
uninitialized.

Reported-by: Coverity (CID: 167335)
Reported-by: Coverity (CID: 167336)
Reported-by: Coverity (CID: 167337)
Signed-off-by: Marek Behun <marek.behun@nic.cz>
---
 fs/btrfs/chunk-map.c | 2 +-
 fs/btrfs/dir-item.c  | 2 +-
 fs/btrfs/inode.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/chunk-map.c b/fs/btrfs/chunk-map.c
index 48407f3331..ce7330b1b7 100644
--- a/fs/btrfs/chunk-map.c
+++ b/fs/btrfs/chunk-map.c
@@ -147,7 +147,7 @@ int btrfs_read_chunk_tree(void)
 	struct btrfs_path path;
 	struct btrfs_key key, *found_key;
 	struct btrfs_chunk *chunk;
-	int res;
+	int res = 0;
 
 	key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
 	key.type = BTRFS_CHUNK_ITEM_KEY;
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index decf86eb53..970563404f 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -93,7 +93,7 @@ int btrfs_readdir(const struct btrfs_root *root, u64 dir,
 	struct btrfs_path path;
 	struct btrfs_key key, *found_key;
 	struct btrfs_dir_item *item;
-	int res;
+	int res = 0;
 
 	key.objectid = dir;
 	key.type = BTRFS_DIR_INDEX_KEY;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0d3da28296..0af04278a3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -324,7 +324,7 @@ u64 btrfs_file_read(const struct btrfs_root *root, u64 inr, u64 offset,
 	struct btrfs_path path;
 	struct btrfs_key key;
 	struct btrfs_file_extent_item *extent;
-	int res;
+	int res = 0;
 	u64 rd, rd_all = -1ULL;
 
 	key.objectid = inr;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier
  2017-10-06 13:04 [U-Boot] [PATCH 1/4] linux/time.h: Remove dead code Marek Behún
  2017-10-06 13:04 ` [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables Marek Behún
@ 2017-10-06 13:04 ` Marek Behún
  2017-10-06 13:14   ` Marek Behún
  2017-10-06 13:04 ` [U-Boot] [PATCH 4/4] fs: btrfs: Remove a foreign language note Marek Behún
  2017-10-17  0:47 ` [U-Boot] [U-Boot,1/4] linux/time.h: Remove dead code Tom Rini
  3 siblings, 1 reply; 10+ messages in thread
From: Marek Behún @ 2017-10-06 13:04 UTC (permalink / raw)
  To: u-boot

Change %lu to %u. The compiler issues a warning otherwise.

Signed-off-by: Marek Behun <marek.behun@nic.cz>
---
 fs/btrfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 2529c2b3b6..706286ee2d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -147,7 +147,7 @@ static int btrfs_check_super(struct btrfs_super_block *sb)
 
 	if (sb->sys_chunk_array_size < sizeof(struct btrfs_key) +
 	    sizeof(struct btrfs_chunk)) {
-		printf("%s: system chunk array too small %u < %lu\n", __func__,
+		printf("%s: system chunk array too small %u < %u\n", __func__,
 		       sb->sys_chunk_array_size, (u32) sizeof(struct btrfs_key)
 		       + sizeof(struct btrfs_chunk));
 		ret = -1;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 4/4] fs: btrfs: Remove a foreign language note
  2017-10-06 13:04 [U-Boot] [PATCH 1/4] linux/time.h: Remove dead code Marek Behún
  2017-10-06 13:04 ` [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables Marek Behún
  2017-10-06 13:04 ` [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier Marek Behún
@ 2017-10-06 13:04 ` Marek Behún
  2017-10-17  0:47   ` [U-Boot] [U-Boot, " Tom Rini
  2017-10-17  0:47 ` [U-Boot] [U-Boot,1/4] linux/time.h: Remove dead code Tom Rini
  3 siblings, 1 reply; 10+ messages in thread
From: Marek Behún @ 2017-10-06 13:04 UTC (permalink / raw)
  To: u-boot

I accidentaly left a foreign language note in the code from development.

Signed-off-by: Marek Behun <marek.behun@nic.cz>
---
 fs/btrfs/inode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0af04278a3..f785b600fa 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -210,7 +210,6 @@ static inline const char *skip_current_directories(const char *cur)
 	return cur;
 }
 
-/* inode.c, musi vratit aj root stromu kde sa inoda najde */
 u64 btrfs_lookup_path(struct btrfs_root *root, u64 inr, const char *path,
 		      u8 *type_p, struct btrfs_inode_item *inode_item_p,
 		      int symlink_limit)
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier
  2017-10-06 13:04 ` [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier Marek Behún
@ 2017-10-06 13:14   ` Marek Behún
  2017-10-06 14:23     ` Tom Rini
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Behún @ 2017-10-06 13:14 UTC (permalink / raw)
  To: u-boot

Hmm, this is weird. Tom's commit 6b7fd350

http://git.denx.de/?p=u-boot.git;a=commit;h=6b7fd350e85a97892a2cb066364797f3f3dcb9c9

forces %lu here, because the %u issued a warning.
But my compiler warns when %lu is used.
Maybe we should use PRIu32 instead...

...

On Fri,  6 Oct 2017 15:04:58 +0200
Marek Behún <marek.behun@nic.cz> wrote:

> Change %lu to %u. The compiler issues a warning otherwise.
> 
> Signed-off-by: Marek Behun <marek.behun@nic.cz>
> ---
>  fs/btrfs/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 2529c2b3b6..706286ee2d 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -147,7 +147,7 @@ static int btrfs_check_super(struct
> btrfs_super_block *sb) 
>  	if (sb->sys_chunk_array_size < sizeof(struct btrfs_key) +
>  	    sizeof(struct btrfs_chunk)) {
> -		printf("%s: system chunk array too small %u <
> %lu\n", __func__,
> +		printf("%s: system chunk array too small %u < %u\n",
> __func__, sb->sys_chunk_array_size, (u32) sizeof(struct btrfs_key)
>  		       + sizeof(struct btrfs_chunk));
>  		ret = -1;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier
  2017-10-06 13:14   ` Marek Behún
@ 2017-10-06 14:23     ` Tom Rini
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-10-06 14:23 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 06, 2017 at 03:14:53PM +0200, Marek Behún wrote:
> Hmm, this is weird. Tom's commit 6b7fd350
> 
> http://git.denx.de/?p=u-boot.git;a=commit;h=6b7fd350e85a97892a2cb066364797f3f3dcb9c9
> 
> forces %lu here, because the %u issued a warning.
> But my compiler warns when %lu is used.
> Maybe we should use PRIu32 instead...

Yes, oops :)

> 
> ...
> 
> On Fri,  6 Oct 2017 15:04:58 +0200
> Marek Behún <marek.behun@nic.cz> wrote:
> 
> > Change %lu to %u. The compiler issues a warning otherwise.
> > 
> > Signed-off-by: Marek Behun <marek.behun@nic.cz>
> > ---
> >  fs/btrfs/super.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> > index 2529c2b3b6..706286ee2d 100644
> > --- a/fs/btrfs/super.c
> > +++ b/fs/btrfs/super.c
> > @@ -147,7 +147,7 @@ static int btrfs_check_super(struct
> > btrfs_super_block *sb) 
> >  	if (sb->sys_chunk_array_size < sizeof(struct btrfs_key) +
> >  	    sizeof(struct btrfs_chunk)) {
> > -		printf("%s: system chunk array too small %u <
> > %lu\n", __func__,
> > +		printf("%s: system chunk array too small %u < %u\n",
> > __func__, sb->sys_chunk_array_size, (u32) sizeof(struct btrfs_key)
> >  		       + sizeof(struct btrfs_chunk));
> >  		ret = -1;
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171006/4cec6128/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables
       [not found]   ` <99f56d19-544c-4604-4f82-bd7a9a1e45b6@comcast.net>
@ 2017-10-06 14:28     ` Marek Behún
  0 siblings, 0 replies; 10+ messages in thread
From: Marek Behún @ 2017-10-06 14:28 UTC (permalink / raw)
  To: u-boot

On Fri, 6 Oct 2017 06:54:34 -0700
"J. William Campbell" <jwilliamcampbell@comcast.net> wrote:

> Hi Marek,
>          If the searched key is not found, isn't it an error to use
> the res value AT ALL? Setting it to 0 may cover up the warning, but
> the function shouldn't actually use it for anything. If it does, it
> is modifying an element that doesn't match the search key.

Hi Bill,

the res variable is just an indicator if an error occured.
In these functions if no key is found, it is not an error (for example
if no key is found in btrfs_readdir, it just means the directory is
empty, which is not an error).

Marek

> 
> Best Regards,
> Bill Campbell

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [U-Boot,1/4] linux/time.h: Remove dead code
  2017-10-06 13:04 [U-Boot] [PATCH 1/4] linux/time.h: Remove dead code Marek Behún
                   ` (2 preceding siblings ...)
  2017-10-06 13:04 ` [U-Boot] [PATCH 4/4] fs: btrfs: Remove a foreign language note Marek Behún
@ 2017-10-17  0:47 ` Tom Rini
  3 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-10-17  0:47 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 06, 2017 at 03:04:56PM +0200, Marek Behún wrote:

> Since
>   rem = ((long) *tim_p) % SECSPERDAY;
> the second while cycle
>   while (rem >= SECSPERDAY)
> is dead.
> 
> Reported-by: Coverity (CID: 167334)
> Signed-off-by: Marek Behun <marek.behun@nic.cz>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171016/761c9f67/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [U-Boot, 2/4] fs: btrfs: Fix usage of uninitialized variables
  2017-10-06 13:04 ` [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables Marek Behún
       [not found]   ` <99f56d19-544c-4604-4f82-bd7a9a1e45b6@comcast.net>
@ 2017-10-17  0:47   ` Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-10-17  0:47 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 06, 2017 at 03:04:57PM +0200, Marek Behún wrote:

> The variable res should be initialized to 0 in these functions,
> because if the searched key is not found, the variable is used
> uninitialized.
> 
> Reported-by: Coverity (CID: 167335)
> Reported-by: Coverity (CID: 167336)
> Reported-by: Coverity (CID: 167337)
> Signed-off-by: Marek Behun <marek.behun@nic.cz>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171016/b2a6f7ad/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [U-Boot, 4/4] fs: btrfs: Remove a foreign language note
  2017-10-06 13:04 ` [U-Boot] [PATCH 4/4] fs: btrfs: Remove a foreign language note Marek Behún
@ 2017-10-17  0:47   ` Tom Rini
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-10-17  0:47 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 06, 2017 at 03:04:59PM +0200, Marek Behún wrote:

> I accidentaly left a foreign language note in the code from development.
> 
> Signed-off-by: Marek Behun <marek.behun@nic.cz>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171016/71171784/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-10-17  0:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-06 13:04 [U-Boot] [PATCH 1/4] linux/time.h: Remove dead code Marek Behún
2017-10-06 13:04 ` [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables Marek Behún
     [not found]   ` <99f56d19-544c-4604-4f82-bd7a9a1e45b6@comcast.net>
2017-10-06 14:28     ` Marek Behún
2017-10-17  0:47   ` [U-Boot] [U-Boot, " Tom Rini
2017-10-06 13:04 ` [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier Marek Behún
2017-10-06 13:14   ` Marek Behún
2017-10-06 14:23     ` Tom Rini
2017-10-06 13:04 ` [U-Boot] [PATCH 4/4] fs: btrfs: Remove a foreign language note Marek Behún
2017-10-17  0:47   ` [U-Boot] [U-Boot, " Tom Rini
2017-10-17  0:47 ` [U-Boot] [U-Boot,1/4] linux/time.h: Remove dead code Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.