cifs-utils: fix some sparse warnings
authorJeff Layton <jlayton@samba.org>
Thu, 18 Jul 2013 14:14:21 +0000 (10:14 -0400)
committerJeff Layton <jlayton@samba.org>
Thu, 18 Jul 2013 14:14:21 +0000 (10:14 -0400)
Signed-off-by: Jeff Layton <jlayton@samba.org>
cifs.idmap.c
cifs.upcall.c
cifscreds.c
cifsidmap.h
idmap_plugin.c
mount.cifs.c
mtab.c
replace.h
util.c
util.h

index 788d3697ba2d9c0e847f5de5c900e4f398758500..cbc01c5414566767a14851e293f04b797568f875 100644 (file)
@@ -60,7 +60,8 @@ static void usage(void)
        fprintf(stderr, "Usage: %s [-h] [-v] [-t timeout] key_serial\n", prog);
 }
 
-char *strget(const char *str, const char *substr)
+static char *
+strget(const char *str, const char *substr)
 {
        int sublen;
        char *substrptr;
index c16bdfd144e863e357538d635c7ee5c9192821f1..20b562f036066631cf832301112d675a3320e024 100644 (file)
@@ -244,7 +244,7 @@ init_cc_from_keytab(const char *keytab_name, const char *user)
        if (ccname == NULL)
                syslog(LOG_ERR, "Unable to allocate memory");
 icfk_cleanup:
-       my_creds.client = 0;
+       my_creds.client = (krb5_principal)0;
        krb5_free_cred_contents(context, &my_creds);
 
        if (me)
@@ -808,7 +808,7 @@ static void usage(void)
        fprintf(stderr, "Usage: %s [ -K /path/to/keytab] [-k /path/to/krb5.conf] [-t] [-v] [-l] key_serial\n", prog);
 }
 
-const struct option long_options[] = {
+static const struct option long_options[] = {
        {"krb5conf", 1, NULL, 'k'},
        {"legacy-uid", 0, NULL, 'l'},
        {"trust-dns", 0, NULL, 't'},
index bb35c02e5195a17e715d94891b874dae0fdb86a8..60be4e5733909a8e00875321aa225a139556add8 100644 (file)
@@ -75,9 +75,9 @@ static int cifscreds_clear(struct cmdarg *arg);
 static int cifscreds_clearall(struct cmdarg *arg);
 static int cifscreds_update(struct cmdarg *arg);
 
-const char *thisprogram;
+static const char *thisprogram;
 
-struct command commands[] = {
+static struct command commands[] = {
        { cifscreds_add,        "add",          "[-u username] [-d] <host|domain>" },
        { cifscreds_clear,      "clear",        "[-u username] [-d] <host|domain>" },
        { cifscreds_clearall,   "clearall",     "" },
@@ -85,7 +85,7 @@ struct command commands[] = {
        { NULL, "", NULL }
 };
 
-struct option longopts[] = {
+static struct option longopts[] = {
        {"username", 1, NULL, 'u'},
        {"domain", 0, NULL, 'd' },
        {NULL, 0, NULL, 0}
index 3c074ae37dc2b02cba6610a719b5cb6d48ddfdfd..664b84f8d1c55c050fb02eac9c19a97e510fb187 100644 (file)
@@ -70,9 +70,8 @@ struct cifs_uxid {
  * and in subsequent idmapping functions. On any error, the plugin
  * should point *errmsg at a string describing that error. Returns 0
  * on success and non-zero on error.
- *
- * int cifs_idmap_init_plugin(void **handle, const char **errmsg);
  */
+extern int cifs_idmap_init_plugin(void **handle, const char **errmsg);
 
 /**
  * cifs_idmap_exit_plugin - Destroy an idmapping context
@@ -82,9 +81,8 @@ struct cifs_uxid {
  * this function to destroy any context that was created during the
  * init_plugin. The handle passed back in was the one given by the init
  * routine.
- *
- * void cifs_idmap_exit_plugin(void *handle);
  */
+extern void cifs_idmap_exit_plugin(void *handle);
 
 /**
  * cifs_idmap_sid_to_str - convert cifs_sid to a string
@@ -98,10 +96,9 @@ struct cifs_uxid {
  * success and non-zero on error. On error, the errmsg pointer passed
  * in to the init_plugin function should point to an error string. The
  * caller will not free the error string.
- *
- * int cifs_idmap_sid_to_str(void *handle, const struct cifs_sid *sid,
- *                             char **name);
  */
+extern int cifs_idmap_sid_to_str(void *handle, const struct cifs_sid *sid,
+                                       char **name);
 
 /**
  * cifs_idmap_str_to_sid - convert string to struct cifs_sid
@@ -114,10 +111,9 @@ struct cifs_uxid {
  * allocated. Returns 0 on success and non-zero on error. On error, the
  * plugin should reset the errmsg pointer passed to the init_plugin
  * function to an error string. The caller will not free the error string.
- *
- * int cifs_idmap_str_to_sid(void *handle, const char *name,
- *                             struct cifs_sid *sid);
  */
+extern int cifs_idmap_str_to_sid(void *handle, const char *name,
+                               struct cifs_sid *sid);
 
 /**
  * cifs_idmap_sids_to_ids - convert struct cifs_sids to struct cifs_uxids
@@ -136,10 +132,9 @@ struct cifs_uxid {
  * On any error, the plugin should reset the errmsg pointer passed to the
  * init_plugin function to an error string. The caller will not free the error
  * string.
- *
- * int cifs_idmap_sids_to_ids(void *handle, const struct cifs_sid *sid,
- *                             const size_t num, struct cifs_uxid *cuxid);
  */
+extern int cifs_idmap_sids_to_ids(void *handle, const struct cifs_sid *sid,
+                               const size_t num, struct cifs_uxid *cuxid);
 
 /**
  * cifs_idmap_ids_to_sids - convert uid to struct cifs_sid
@@ -157,9 +152,7 @@ struct cifs_uxid {
  * On any error, the plugin should reset the errmsg pointer passed to the
  * init_plugin function to an error string. The caller will not free the error
  * string.
- *
- * int cifs_idmap_ids_to_sids(void *handle, const struct cifs_uxid *cuxid,
- *                             const size_t num, struct cifs_sid *sid);
  */
-
+extern int cifs_idmap_ids_to_sids(void *handle, const struct cifs_uxid *cuxid,
+                               const size_t num, struct cifs_sid *sid);
 #endif /* _CIFSIDMAP_H */
index 19050ecdbf879918b12094818f94b95c067b4844..8fcb84607d3562b92af2ce2c69e159bc8bae2694 100644 (file)
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 
 #include "cifsidmap.h"
+#include "idmap_plugin.h"
 
 const char *plugin_errmsg;
 static void *plugin;
index 3b2b89ea90d1a01682e736fa88663dde7700622a..12f1b8e7065e7d5437f61904023d9b5f03d0d4ad 100644 (file)
@@ -182,8 +182,8 @@ struct parsed_mount_info {
        unsigned int nofail:1;
 };
 
-const char *thisprogram;
-const char *cifs_fstype = "cifs";
+static const char *thisprogram;
+static const char *cifs_fstype = "cifs";
 
 static int parse_unc(const char *unc_name, struct parsed_mount_info *parsed_info);
 
@@ -1899,7 +1899,7 @@ int main(int argc, char **argv)
                thisprogram = "mount.cifs";
 
        /* allocate parsed_info as shared anonymous memory range */
-       parsed_info = mmap(0, sizeof(*parsed_info), PROT_READ | PROT_WRITE,
+       parsed_info = mmap((void *)0, sizeof(*parsed_info), PROT_READ | PROT_WRITE,
                           MAP_ANONYMOUS | MAP_SHARED, -1, 0);
        if (parsed_info == (struct parsed_mount_info *) -1) {
                parsed_info = NULL;
diff --git a/mtab.c b/mtab.c
index 3d42ac0888f7b2a921381566fdbb888759e3c413..7b365b373624bd172e1951ffffb49e9be7e455a5 100644 (file)
--- a/mtab.c
+++ b/mtab.c
@@ -62,7 +62,7 @@ setlkw_timeout (int sig __attribute__((unused))) {
 }
 
 /* use monotonic time for timeouts */
-struct timeval
+static struct timeval
 mono_time(void) {
        struct timeval ret;
 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
index a9fdf7e860a13cb6dea8345217a9a98cf85575b1..03d293704a2e5105eee7d8a02f857beb3e16ee28 100644 (file)
--- a/replace.h
+++ b/replace.h
@@ -124,10 +124,6 @@ extern char *sys_errlist[];
 #define strerror(i) sys_errlist[i]
 #endif
 
-#ifndef HAVE_ERRNO_DECL
-extern int errno;
-#endif
-
 #ifndef HAVE_STRDUP
 #define strdup rep_strdup
 char *rep_strdup(const char *s);
diff --git a/util.c b/util.c
index 80d5a80869b6917bf408ae24774a6f2613bbbbeb..546f2843352b552ac130a5a4c556d1b78ceebb7a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 #include <string.h>
 #include <pwd.h>
+#include "util.h"
 
 /* glibc doesn't have strlcpy, strlcat. Ensure we do. JRA. We
  * don't link to libreplace so need them here. */
diff --git a/util.h b/util.h
index d3ca015769f53d17dfb726e6902d6daf8136aafd..2864130f9246a87bd2f5118636a727f5dcecc01d 100644 (file)
--- a/util.h
+++ b/util.h
@@ -25,9 +25,9 @@
 #ifndef _LIBUTIL_H
 #define _LIBUTIL_H
 
-size_t strlcpy(char *d, const char *s, size_t bufsize);
-size_t strlcat(char *d, const char *s, size_t bufsize);
+extern size_t strlcpy(char *d, const char *s, size_t bufsize);
+extern size_t strlcat(char *d, const char *s, size_t bufsize);
 
-char *getusername(uid_t uid);
+extern char *getusername(uid_t uid);
 #endif /* _LIBUTIL_H */