diff options
author | dim <dim@FreeBSD.org> | 2012-08-05 17:23:47 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-05 17:23:47 +0000 |
commit | b74733884ca68eafbe6bad8eabf5a21de0db9ea8 (patch) | |
tree | 0ac39b532cb74d43760f2202da1929d51b1ed966 /usr.sbin/ctladm/ctladm.c | |
parent | ca7848660752fde3ed79474a4629668291f9e12c (diff) | |
download | FreeBSD-src-b74733884ca68eafbe6bad8eabf5a21de0db9ea8.zip FreeBSD-src-b74733884ca68eafbe6bad8eabf5a21de0db9ea8.tar.gz |
In usr.sbin/ctladm/ctladm.c, function cctl_error_inject(), initialize
the 'retval' variable to zero, to avoid returning garbage in several
cases.
This fixes the following clang 3.2 warnings:
usr.sbin/ctladm/ctladm.c:1234:6: error: variable 'retval' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (ioctl(fd, CTL_ERROR_INJECT, &err_desc) == -1) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
usr.sbin/ctladm/ctladm.c:1243:10: note: uninitialized use occurs here
return (retval);
^~~~~~
usr.sbin/ctladm/ctladm.c:1234:2: note: remove the 'if' if its condition is always true
if (ioctl(fd, CTL_ERROR_INJECT, &err_desc) == -1) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
usr.sbin/ctladm/ctladm.c:1161:7: error: variable 'retval' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (ioctl(fd, CTL_ERROR_INJECT_DELETE, &err_desc) == -1) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
usr.sbin/ctladm/ctladm.c:1243:10: note: uninitialized use occurs here
return (retval);
^~~~~~
usr.sbin/ctladm/ctladm.c:1161:3: note: remove the 'if' if its condition is always true
if (ioctl(fd, CTL_ERROR_INJECT_DELETE, &err_desc) == -1) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
usr.sbin/ctladm/ctladm.c:1029:12: note: initialize the variable 'retval' to silence this warning
int retval;
^
= 0
MFC after: 1 week
Diffstat (limited to 'usr.sbin/ctladm/ctladm.c')
-rw-r--r-- | usr.sbin/ctladm/ctladm.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c index 4cdbd42..9497101 100644 --- a/usr.sbin/ctladm/ctladm.c +++ b/usr.sbin/ctladm/ctladm.c @@ -1026,7 +1026,7 @@ static int cctl_error_inject(int fd, uint32_t target, uint32_t lun, int argc, char **argv, char *combinedopt) { - int retval; + int retval = 0; struct ctl_error_desc err_desc; uint64_t lba = 0; uint32_t len = 0; |