volser: restructure GetNextVol and clients to remove duplicate code
authorGarrett Wollman <wollman@csail.mit.edu>
Sat, 28 Jul 2012 05:10:09 +0000 (01:10 -0400)
committerDerrick Brashear <shadow@dementix.org>
Sat, 28 Jul 2012 17:36:28 +0000 (10:36 -0700)
commitb725a28eac2d9a94344b2524f995a98e60ecc2ea
treec7f8b9d5ecfbc0d7e2c30925eb0b05454d9bb8ae
parentcac7bcda084879a876d93eb0480c2f7c76c25a4a
volser: restructure GetNextVol and clients to remove duplicate code

There are several odd-looking but stylized loops involving GetNextVol()
which can be radically simplified if only GetNextVol() would return
a meaningful value.  Move all of the code that skips non-volume-header
files in the directory into GetNextVol and have it return a truth value
(instead of always returning zero) that indicates whether it saw
something that looks like a volume header.  Then all the odd while
loops and strcmps just collapse into while(GetNextVol(...)).

GetNextVol() had external scope, but there are no callers in the
tree that use it outside of volprocs.c, and it's not part of a
public library interface, so make it static.

While here, don't strcmp() past the end of a filename that begins with
'V' but is too short to be a valid volume name.

Change-Id: I214b33c46714959d700608b3d3718c79d3792878
Reviewed-on: http://gerrit.openafs.org/7893
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/vol/voldefs.h
src/volser/volprocs.c