]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Clean up the code to eliminate some clang warnings
authorBen Kaduk <kaduk@mit.edu>
Wed, 30 Oct 2013 18:51:12 +0000 (14:51 -0400)
committerBen Kaduk <kaduk@mit.edu>
Mon, 4 Nov 2013 18:51:17 +0000 (13:51 -0500)
In ure.c, though k is a short, the literal 1 is of type 'int', and
so the operation 'k + 1' is performed at the (32-bit) width of int,
and therefore the "%d" format string is correct.

In accept_sec_context.c, the 'length' field of krb5_data is an
unsigned type, so checking for a negative value has no effect.

In net-server.c, the helper routine rtm_type_name() is only used
in code that is disabled with #if 0 conditionals; make the
definition also disabled in the same way to avoid warnings of an
unused function.

In kdc_authdata.c, equality checks in double parentheses elicit
a warning from clang.  The double-parentheses idiom is normally used
to indicate that an assignment is being performed, but the value of
the assignment is also to be used as the value for the conditional.
Since assignment and equality checking differ only by a single
character, clang considers this worthy of a warning.  Since the extra
set of parentheses is redundant and against style, it is correct to
remove them.

In several places (sim_server.c, dump.c, kdb5_destroy.c,
ovsec_kadmd.c), there are declarations of extern variables relating
to getopt() functionality that are now unused in the code.  Remove
these unused variables.

src/appl/simple/server/sim_server.c
src/kadmin/dbutil/dump.c
src/kadmin/dbutil/kdb5_destroy.c
src/kadmin/server/ovsec_kadmd.c
src/kdc/kdc_authdata.c
src/lib/apputils/net-server.c
src/lib/gssapi/krb5/accept_sec_context.c
src/lib/krb5/unicode/ure/ure.c

index 19d8f5f1801cd68f47a6abfd8a4cc3865a972cd9..fce5a9c6fd6940d73c603903e05a0434244a7720 100644 (file)
@@ -73,7 +73,6 @@ main(int argc, char *argv[])
     struct sockaddr_in c_sock;          /* client's address */
     char full_hname[MAXHOSTNAMELEN];
     char *cp;
-    extern int opterr, optind;
     extern char * optarg;
     int ch;
 
@@ -100,7 +99,6 @@ main(int argc, char *argv[])
      * Parse command line arguments
      *
      */
-    opterr = 0;
     while ((ch = getopt(argc, argv, "p:s:S:")) != -1) {
         switch (ch) {
         case 'p':
index d4e80908a962e2384e100cea1067665d298b0690..8bff367eb9592b0773d5e29648a6d4b5b870a58a 100644 (file)
@@ -1479,8 +1479,6 @@ load_db(int argc, char **argv)
 {
     krb5_error_code ret;
     FILE *f = NULL;
-    extern char *optarg;
-    extern int optind;
     char *dumpfile = NULL, *dbname, buf[BUFSIZ];
     dump_version *load = NULL;
     int aindex;
index f32988a6de206775e8152ce94ebf90fd6f5cd8b8..e5895523b64a9c7bbec2cd1a8c926a5668196524 100644 (file)
@@ -43,7 +43,6 @@ kdb5_destroy(argc, argv)
     int argc;
     char *argv[];
 {
-    extern char *optarg;
     extern int optind;
     int optchar;
     char *dbname;
index 37e66316e21fcb5dd212a8888b3f281701acc8ee..1273b07119952060dcc06a5bac4ccbec64b40ba2 100644 (file)
@@ -210,8 +210,6 @@ char *dump_file = KPROP_DEFAULT_FILE;
 
 int main(int argc, char *argv[])
 {
-    extern     char *optarg;
-    extern     int optind, opterr;
     int ret;
     OM_uint32 OMret, major_status, minor_status;
     char *whoami;
index 731c7d5d1c9475f32be84712ddcdcc4946cce41a..e70a27b838a19a070e1c3a46789e1ec063b49a67 100644 (file)
@@ -280,7 +280,7 @@ load_authdata_plugins(krb5_context context)
             void *pctx = NULL;
 
             ftable = authdata_plugins_ftables_v2[i];
-            if ((ftable->authdata_proc == NULL)) {
+            if (ftable->authdata_proc == NULL) {
                 continue;
             }
             server_init_proc = ftable->init_proc;
@@ -316,7 +316,7 @@ load_authdata_plugins(krb5_context context)
             void *pctx = NULL;
 
             ftable = authdata_plugins_ftables_v0[i];
-            if ((ftable->authdata_proc == NULL)) {
+            if (ftable->authdata_proc == NULL) {
                 continue;
             }
             server_init_proc = ftable->init_proc;
index 7780b8a7db307077a1a12294f21fbf95ba06ed13..b4be585d486dcaec2b38903e7ba29a1421696431 100644 (file)
@@ -983,6 +983,7 @@ setup_udp_port(void *P_data, struct sockaddr *addr)
 #ifdef HAVE_STRUCT_RT_MSGHDR
 #include <net/route.h>
 
+#if 0
 static char *
 rtm_type_name(int type)
 {
@@ -1006,6 +1007,7 @@ rtm_type_name(int type)
     default: return "?";
     }
 }
+#endif
 
 static void
 do_network_reconfig(verto_ctx *ctx, verto_ev *ev)
index 82f03b7cc60eb7b5a5765a37f2f9e09c2b3a05ee..f3a9803cca70dc66ed9187ad0d64a475e9ec81d3 100644 (file)
@@ -791,7 +791,7 @@ kg_accept_krb5(minor_status, context_handle,
                 TREAD_INT16(ptr, option.length, 0);
                 i -= 4;
 
-                if (i < option.length || option.length < 0) {
+                if (i < option.length) {
                     code = KG_BAD_LENGTH;
                     major_status = GSS_S_FAILURE;
                     goto fail;
index 91ef7c95bbc0537e8ea557a4a8ab5b356dc8f700..b3fa986bdfd137c5561a7cd8c98848838d359bf8 100644 (file)
@@ -1864,7 +1864,7 @@ ure_write_dfa(ure_dfa_t dfa, FILE *out)
                     if (sym->props & (1 << k)) {
                         if (h != 0)
                           putc(',', out);
-                        fprintf(out, "%hd", k + 1);
+                        fprintf(out, "%d", k + 1);
                         h = 1;
                     }
                 }