[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dd.c: code issue, assignment with no effect
From: |
Jim Meyering |
Subject: |
Re: dd.c: code issue, assignment with no effect |
Date: |
Thu, 30 Mar 2006 15:33:46 +0200 |
Felix Rauch Valenti <address@hidden> wrote:
> While working on a prototype for a static analysis tool, we found the
> following issue in dd.c of coreutils version 5.94.
>
> The assignment in the following line of the function iwrite() has no
> effect (line number 755 of dd.c):
> nwritten = -1;
>
> Right after the assignment is a 'break' statement, which exits the
> while loop and also the scope of the variable 'nwritten'. Hence, the
> assigned value of '-1' can never be used.
Thank you for reporting that.
I've removed the unnecessary line.
2006-03-30 Jim Meyering <address@hidden>
* src/dd.c (iwrite): Remove assignment without effect.
Reported by Felix Rauch Valenti.
Index: src/dd.c
===================================================================
RCS file: /fetish/cu/src/dd.c,v
retrieving revision 1.192
diff -u -p -r1.192 dd.c
--- src/dd.c 8 Mar 2006 18:57:39 -0000 1.192
+++ src/dd.c 30 Mar 2006 13:24:51 -0000
@@ -761,7 +761,6 @@ iwrite (int fd, char const *buf, size_t
a device's end. (Example: Linux 1.2.13 on /dev/fd0.)
Set errno to ENOSPC so they get a sensible diagnostic. */
errno = ENOSPC;
- nwritten = -1;
break;
}
else
> We do not know whether the assignment was inserted erroneously or
> whether some other code was removed from the code that rendered the
> assignment useless.
I don't know either.
You're welcome to check the logs.