Skip to content

Commit

Permalink
lib: tidy up "unused" warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bron Gondwana committed Jun 15, 2011
1 parent 784e9aa commit fa69795
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 56 deletions.
7 changes: 4 additions & 3 deletions lib/auth_krb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct auth_state {
*/
static int mymemberof(struct auth_state *auth_state, const char *identifier)
{
char *ident;
const char *ident;
int ret=0;

if (strcmp(identifier,"anyone") == 0) return 1;
Expand All @@ -86,7 +86,7 @@ static int mymemberof(struct auth_state *auth_state, const char *identifier)

ident = auth_canonifyid(identifier,0);

if(!strcmp(ident, auth_state->userid)) {
if (!strcmp(ident, auth_state->userid)) {
ret = 3;
}

Expand Down Expand Up @@ -181,7 +181,8 @@ static const char *mycanonifyid(const char *identifier, size_t len)
static struct auth_state *mynewstate(const char *identifier)
{
struct auth_state *newstate;
char *ident;
const char *ident;

ident = auth_canonifyid(identifier, 0);
if (!ident) return NULL;

Expand Down
19 changes: 4 additions & 15 deletions lib/auth_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,11 @@ static const char *mycanonifyid(const char *identifier, size_t len)
{
static char retbuf[81];
struct group *grp;
char sawalpha;
char *p;
int username_tolower = 0;

if(!len) len = strlen(identifier);
if(len >= sizeof(retbuf)) return NULL;
if (!len) len = strlen(identifier);
if (len >= sizeof(retbuf)) return NULL;

memmove(retbuf, identifier, len);
retbuf[len] = '\0';
Expand All @@ -185,28 +184,18 @@ static const char *mycanonifyid(const char *identifier, size_t len)
* Lowercase usernames if requested.
*/
username_tolower = libcyrus_config_getswitch(CYRUSOPT_USERNAME_TOLOWER);
sawalpha = 0;
for(p = retbuf; *p; p++) {
for (p = retbuf; *p; p++) {
if (username_tolower && Uisupper(*p))
*p = tolower((unsigned char)*p);

switch (allowedchars[*(unsigned char*) p]) {
case 0:
return NULL;

case 2:
sawalpha = 1;
/* FALL THROUGH */

default:
;
break;
}
}

/* we used to enforce "has to be one alpha char" */
/* now we don't */
/* if (!sawalpha) return NULL; */

return retbuf;
}

Expand Down
2 changes: 0 additions & 2 deletions lib/cyrusdb_skiplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ static int myopen(const char *fname, int flags, struct db **ret)
struct db *db;
struct db_list *list_ent = open_db;
int r;
int new = 0;

while (list_ent && strcmp(list_ent->db->fname, fname)) {
list_ent = list_ent->next;
Expand Down Expand Up @@ -798,7 +797,6 @@ static int myopen(const char *fname, int flags, struct db **ret)
return CYRUSDB_IOERROR;
}
db->fd = open(fname, O_RDWR | O_CREAT, 0644);
new = 1;
}

if (db->fd == -1) {
Expand Down
57 changes: 22 additions & 35 deletions lib/imclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,6 @@ static int verify_error = X509_V_OK;

#define CCERT_BUFSIZ 256
static char peer_CN[CCERT_BUFSIZ];
static char issuer_CN[CCERT_BUFSIZ];

/*
* Set up the cert things on the server side. We do need both the
Expand Down Expand Up @@ -1823,56 +1822,52 @@ static void apps_ssl_info_callback(SSL * s, int where, int ret)
int tls_start_clienttls(struct imclient *imclient,
unsigned *layer, char **authid, int fd)
{
int sts;
int sts;
SSL_SESSION *session;
SSL_CIPHER *cipher;
X509 *peer;
const SSL_CIPHER *cipher;
X509 *peer;
int tls_cipher_usebits = 0;
int tls_cipher_algbits = 0;
char *tls_peer_CN = "";
char *tls_issuer_CN = NULL;

if (imclient->tls_conn == NULL) {
if (!imclient->tls_conn)
imclient->tls_conn = (SSL *) SSL_new(imclient->tls_ctx);
}
if (imclient->tls_conn == NULL) {

if (!imclient->tls_conn) {
printf("Could not allocate 'con' with SSL_new()\n");
return -1;
}

SSL_clear(imclient->tls_conn);

if (!SSL_set_fd(imclient->tls_conn, fd)) {
printf("SSL_set_fd failed\n");
return -1;
printf("SSL_set_fd failed\n");
return -1;
}

/*SSL_set_read_ahead(imclient->tls_conn, 1);*/

/*
* This is the actual handshake routine. It will do all the negotiations
* and will check the client cert etc.
*/
SSL_set_connect_state(imclient->tls_conn);


/*
* We do have an SSL_set_fd() and now suddenly a BIO_ routine is called?
* Well there is a BIO below the SSL routines that is automatically
* created for us, so we can use it for debugging purposes.
*/
/* if (verbose==1) */
/* BIO_set_callback(SSL_get_rbio(imclient->tls_conn), bio_dump_cb);*/

/* Dump the negotiation for loglevels 3 and 4 */

if ((sts = SSL_connect(imclient->tls_conn)) <= 0) {
sts = SSL_connect(imclient->tls_conn);
if (sts <= 0) {
printf("[ SSL_connect error %d ]\n", sts); /* xxx get string error? */
session = SSL_get_session(imclient->tls_conn);
if (session) {
SSL_CTX_remove_session(imclient->tls_ctx, session);
printf("[ SSL session removed ]\n");
}
if (imclient->tls_conn!=NULL)
if (imclient->tls_conn)
SSL_free(imclient->tls_conn);
imclient->tls_conn = NULL;
return -1;
Expand All @@ -1883,40 +1878,32 @@ int tls_start_clienttls(struct imclient *imclient,
* the actual information. We want to save it for later use.
*/
peer = SSL_get_peer_certificate(imclient->tls_conn);
if (peer != NULL) {
if (peer) {
X509_NAME_get_text_by_NID(X509_get_subject_name(peer),
NID_commonName, peer_CN, CCERT_BUFSIZ);
NID_commonName, peer_CN, CCERT_BUFSIZ);
tls_peer_CN = peer_CN;
X509_NAME_get_text_by_NID(X509_get_issuer_name(peer),
NID_commonName, issuer_CN, CCERT_BUFSIZ);
/* if (verbose==1)
printf("subject_CN=%s, issuer_CN=%s\n", peer_CN, issuer_CN);*/
tls_issuer_CN = issuer_CN;

}

cipher = SSL_get_current_cipher(imclient->tls_conn);
tls_cipher_usebits = SSL_CIPHER_get_bits(cipher,
&tls_cipher_algbits);
&tls_cipher_algbits);

if (layer!=NULL)
*layer = tls_cipher_usebits;
if (layer)
*layer = tls_cipher_usebits;

if (authid!=NULL)
*authid = tls_peer_CN;
if (authid)
*authid = tls_peer_CN;

/* printf("TLS connection established: %s with cipher %s (%d/%d bits)\n",
tls_protocol, tls_cipher_name,
tls_cipher_usebits, tls_cipher_algbits);*/
return 0;
}
#endif /* HAVE_SSL */

int imclient_havetls(void)
{
#ifdef HAVE_SSL
return 1;
return 1;
#else
return 0;
return 0;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ int parsenum(const char *p, const char **ptr, int maxlen, bit64 *res)
if (!cyrus_isdigit(p[n]))
break;
cval = p[n] - '0';
result = result * 10 + (p[n] - '0');
result = result * 10 + cval;
}

/* no characters found... */
Expand Down

0 comments on commit fa69795

Please sign in to comment.