From 15b940351e88da5cb3d68d71887196f89a13e0de Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 30 Oct 2012 14:06:22 -0400 Subject: [PATCH] mountd: Make local functions static Removed a couple Wmissing-prototypes warnings in the mountd code. Once the parse_fsid() function was made static, the compiler detected execution paths through it that did not initialize some fields in *parsed. [ I'm pretty sure these problems are currently harmless, since each path is taken depending on the value of the .fsidtype field. Each path accesses only the fields in *parsed that it cares about. ] This is because parsed_fsid isn't a union type. parse_fsid() leaves uninitialized fields that are not used by a particular fsidtype. To prevent an accidental dereference of stack garbage (.fhuuid being an example of a pointer that is left uninitialized sometimes), have parse_fsid() defensively pre-initialize *parsed to zero. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson --- utils/mountd/cache.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index 70e1aa4..57a3fed 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -370,11 +370,13 @@ struct parsed_fsid { char *fhuuid; }; -int parse_fsid(int fsidtype, int fsidlen, char *fsid, struct parsed_fsid *parsed) +static int parse_fsid(int fsidtype, int fsidlen, char *fsid, + struct parsed_fsid *parsed) { unsigned int dev; unsigned long long inode64; + memset(parsed, 0, sizeof(*parsed)); parsed->fsidtype = fsidtype; switch(fsidtype) { case FSID_DEV: /* 4 bytes: 2 major, 2 minor, 4 inode */ @@ -501,7 +503,7 @@ static bool match_fsid(struct parsed_fsid *parsed, nfs_export *exp, char *path) return false; } -struct addrinfo *lookup_client_addr(char *dom) +static struct addrinfo *lookup_client_addr(char *dom) { struct addrinfo *ret; struct addrinfo *tmp; -- 2.39.5