diff options
author | Jeffrey Hutzelman <jhutz@cmu.edu> | 2013-02-02 02:09:25 -0500 |
---|---|---|
committer | Jeffrey Hutzelman <jhutz@cmu.edu> | 2013-02-14 19:20:27 -0500 |
commit | e2bfb6322ce9f4323b83469dc06dd1ce1b0f4cf6 (patch) | |
tree | 507dab2f064c09996a002624d49c0dfb257a24a9 /lib/Zinternal.c | |
parent | 350312d5db9b0a968bbbbecb37bd600a2da389d0 (diff) |
Clean up warnings
Eliminate compiler warnings due to various issues (listed below). This
allows Zephyr to build cleanly under GCC versions ranging from 4.1.0 to
4.7.2 with all of the options shown below:
-g -O2 -Wall -Werror
-Wno-deprecated-declarations
-Wmissing-declarations
-Wpointer-arith
-Wstrict-prototypes
-Wshadow
-Wextra
-Wno-missing-field-initializers
-Wno-unused-parameter
and, on recent versions, -Wunreachable-code
Test builds were done
- On Ubuntu 12.10 (Quantal Quetzal) using both MIT Kerberos 1.10.1 and
Heimdal 1.6, without krb4 and both with and without C-Ares and Hesiod
- On Fedora 14 using Heimdal 0.6, without C-Ares or Hesiod and both
with and without krb4 (KTH Kerberos 1.3rc2)
- On Fedora Core 3, Fedora Core 5, Fedora 7, and Fedora 10, using
Heimdal 0.6 and without C-Ares, Hesiod, or krb4
It also allows clean builds on Solaris 10 under the Sun Studio 12 (9/07)
C compiler with the following options:
-g -fd -v -errfmt -errhdr=%user -errtags=yes -errwarn=%all
-erroff=E_OLD_STYLE_FUNC_DECL,E_ENUM_TYPE_MISMATCH_ARG,E_ARG_INCOMPATIBLE_WITH_ARG
... and under Solaris 9 with the Sun Forte 7 (3/02) C compiler with the above
options and -erroff=E_FUNC_HAS_NO_RETURN_STMT. Solaris builds were done
with Heimdal 0.6 and without C-Ares, Hesiod, or krb4.
The following types of issues are addressed in this change:
- Parameters and local variables with the same names as library functions
- Parameters and local variables with the same names as globals
- Declarations for exported global variables missing from headers
- Prototypes for exported functions missing from headers
- Missing 'static' on functions that shouldn't be exported
- Old-style function declarations
- Duplicate declarations
- Type mismatches
- Unused variables and functions
- Uninitialized variables
- Forward references to enums
- Necessary header files not included
- Violations of the aliasing rules, where GCC was able to detect them
- Missing braces on if blocks that might be empty
- Attempts to do pointer arithmetic on pointers of type void *, which
is not permitted in standard C.
- An attempt to pass a function pointer via a void * parameter, which is
not permitted in standard C. Instead, we now pass a pointer to a
structure, which then contains the required function pointer.
- Unnecessary inclusion of <krb5_err.h>, which is already included by
<krb5.h> when the former exists, and might not be protected against
double inclusion, depending on which com_err was used.
- Missing include of <com_err.h>, which was masked by the fact that it is
included by headers generated by e2fsprogs compile_et
- Use of com_err() with a non-constant value in place of the format string,
which in every case was a fixed-size buffer in which a message was built
using sprintf(!). Both the calls to sprintf and the fixed-size buffers
have been removed, in favor of just letting com_err() do the formatting.
- Various cases where X library functions expecting a parameter of type
wchar_t * were instead passed a parameter of type XChar2b *. The two
types look similar, but are not the same and are _not_ interchangeable.
- An overly-simplistic configure test which failed to detect existence of
<term.h> on Solaris, due to not including <curses.h>.
- Using the wrong type for the flags output of krb5_auth_con_getflags()
when building against Heimdal. A configure test is added to detect
the correct type.
Diffstat (limited to 'lib/Zinternal.c')
-rw-r--r-- | lib/Zinternal.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/lib/Zinternal.c b/lib/Zinternal.c index 7e3e904..0f692f3 100644 --- a/lib/Zinternal.c +++ b/lib/Zinternal.c @@ -87,7 +87,7 @@ Code_t Z_krb5_lookup_cksumtype(krb5_enctype e, krb5_cksumtype *c) { - int i; + unsigned int i; for (i = 0; i < N_CKSUM_MAP; i++) { if (cksum_map[i].e == e) { @@ -188,12 +188,12 @@ int Z_PacketWaiting(void) { struct timeval tv; - fd_set read; + fd_set readfds; tv.tv_sec = tv.tv_usec = 0; - FD_ZERO(&read); - FD_SET(ZGetFD(), &read); - return (select(ZGetFD() + 1, &read, NULL, NULL, &tv)); + FD_ZERO(&readfds); + FD_SET(ZGetFD(), &readfds); + return (select(ZGetFD() + 1, &readfds, NULL, NULL, &tv)); } @@ -254,7 +254,8 @@ Z_SearchQueue(ZUnique_Id_t *uid, if (ZCompareUID(uid, &qptr->uid) && qptr->kind == kind) return (qptr); next = qptr->next; - if (qptr->timep && (qptr->timep+Z_NOTICETIMELIMIT < tv.tv_sec)) + if (qptr->timep && + (qptr->timep+Z_NOTICETIMELIMIT < (unsigned long)tv.tv_sec)) Z_RemQueue(qptr); qptr = next; } @@ -1154,9 +1155,9 @@ Z_SendFragmentedNotice(ZNotice_t *notice, Code_t Z_XmitFragment(ZNotice_t *notice, char *buf, int len, - int wait) + int waitforack) { - return(ZSendPacket(buf, len, wait)); + return(ZSendPacket(buf, len, waitforack)); } /* For debugging printing */ @@ -1285,14 +1286,13 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock, int cksum1_len; /* length of part after checksum */ krb5_data cksumbuf; krb5_data cksum; - unsigned char *key_data; - int key_len; + unsigned char *cksum_data; + unsigned int cksum_data_len; + char *cksum_out_data; krb5_enctype enctype; krb5_cksumtype cksumtype; Code_t result; - key_data = Z_keydata(keyblock); - key_len = Z_keylen(keyblock); result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype); if (result) return (ZAUTH_FAILED); @@ -1306,19 +1306,22 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock, cksumbuf.data = malloc(cksumbuf.length); if (!cksumbuf.data) return ENOMEM; - memcpy(cksumbuf.data, cksum_start, cksum0_len); - memcpy(cksumbuf.data + cksum0_len, cend, cksum1_len); - memcpy(cksumbuf.data + cksum0_len + cksum1_len, + cksum_data = (unsigned char *)cksumbuf.data; + memcpy(cksum_data, cksum_start, cksum0_len); + memcpy(cksum_data + cksum0_len, cend, cksum1_len); + memcpy(cksum_data + cksum0_len + cksum1_len, notice->z_message, notice->z_message_len); /* compute the checksum */ result = Z_Checksum(&cksumbuf, keyblock, cksumtype, from_server ? Z_KEYUSAGE_SRV_CKSUM : Z_KEYUSAGE_CLT_CKSUM, - (char **)&cksum.data, &cksum.length); + &cksum_out_data, &cksum_data_len); if (result) { free(cksumbuf.data); return result; } + cksum.data = cksum_out_data; + cksum.length = cksum_data_len; /* * OK.... we can zcode to a space starting at 'cstart', @@ -1332,7 +1335,7 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock, free(cksum.data); if (!result) { int zcode_len = strlen(cstart) + 1; - memcpy(cstart + zcode_len, cksumbuf.data + cksum0_len, cksum1_len); + memcpy(cstart + zcode_len, cksum_data + cksum0_len, cksum1_len); *length_adjust = zcode_len - cksum_len + (cksum0_len + cksum1_len); } free(cksumbuf.data); @@ -1366,7 +1369,6 @@ Z_krb5_verify_cksum(krb5_keyblock *keyblock, #else krb5_crypto cryptctx; Checksum checksum; - size_t xlen; #endif memset(&checksum, 0, sizeof(checksum)); |