viced: CopyOnWrite2 shouldn't return undefined val
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Sat, 12 Jun 2010 09:26:09 +0000 (10:26 +0100)
committerDerrick Brashear <shadow@dementia.org>
Sun, 13 Jun 2010 05:40:56 +0000 (22:40 -0700)
Unless CopyOnWrite2 encounters the condition where
(rdlen != length) || (wrlen !=length) it will never set a value
for the 'rc' return code, and so return with an undefined value.

Looking at the code, it looks like rc should be 0 in all other
situations, so this patch provides a default value.

Caught by clang-analyzer

Change-Id: If3e528f3d66abb3dde6da2304084f7698c05b863
Reviewed-on: http://gerrit.openafs.org/2141
Reviewed-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/viced/afsfileprocs.c

index b49b4e4..2b36f62 100644 (file)
@@ -1269,7 +1269,7 @@ CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_foff_t off,
     size_t length;
     ssize_t rdlen;
     ssize_t wrlen;
-    int rc;
+    int rc = 0;
 
     FDH_SEEK(targFdP, off, SEEK_SET);
     FDH_SEEK(newFdP, off, SEEK_SET);