Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Aug 2012 17:23:47 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239074 - head/usr.sbin/ctladm
Message-ID:  <201208051723.q75HNl80006961@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sun Aug  5 17:23:47 2012
New Revision: 239074
URL: http://svn.freebsd.org/changeset/base/239074

Log:
  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

Modified:
  head/usr.sbin/ctladm/ctladm.c

Modified: head/usr.sbin/ctladm/ctladm.c
==============================================================================
--- head/usr.sbin/ctladm/ctladm.c	Sun Aug  5 17:04:58 2012	(r239073)
+++ head/usr.sbin/ctladm/ctladm.c	Sun Aug  5 17:23:47 2012	(r239074)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208051723.q75HNl80006961>