From: Arran Cudbard-Bell Date: Fri, 15 Dec 2017 12:34:27 +0000 (+0000) Subject: Fix various compiler clang scan warnings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61da7d1c510079e941ceb042ac008fa778dacba8;p=thirdparty%2Ffreeradius-server.git Fix various compiler clang scan warnings --- diff --git a/src/lib/io/atomic_queue.c b/src/lib/io/atomic_queue.c index a3aca93ed08..6be0855b490 100644 --- a/src/lib/io/atomic_queue.c +++ b/src/lib/io/atomic_queue.c @@ -279,7 +279,7 @@ void fr_atomic_queue_debug(fr_atomic_queue_t *aq, FILE *fp) entry = &aq->entry[i]; - fprintf(fp, "\t[%d] = { %p, %zd }", + fprintf(fp, "\t[%d] = { %p, %" PRId64 " }", i, entry->data, load(entry->seq)); #if 0 if (entry->data) { diff --git a/src/lib/io/network.c b/src/lib/io/network.c index 5052a5487ec..74af457aad6 100644 --- a/src/lib/io/network.c +++ b/src/lib/io/network.c @@ -188,7 +188,7 @@ static void fr_network_drain_input(fr_network_t *nr, fr_channel_t *ch, fr_channe do { nr->num_replies++; - DEBUG3("received reply %zd", nr->num_replies); + DEBUG3("received reply %" PRIu64, nr->num_replies); cd->channel.ch = ch; diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index b3db2e4ae51..d9c3c8048a6 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -1490,8 +1490,10 @@ void fr_worker_debug(fr_worker_t *worker, FILE *fp) fprintf(fp, "\tnum_channels = %d\n", worker->num_channels); fprintf(fp, "\tnum_requests = %d\n", worker->num_requests); - fprintf(fp, "\tcalculated (predicted) total CPU time = %zd\n", worker->tracking.predicted * worker->num_requests); - fprintf(fp, "\tcalculated (counted) per request time = %zd\n", worker->tracking.running / worker->num_requests); + fprintf(fp, "\tcalculated (predicted) total CPU time = %" PRIu64 "\n", + worker->tracking.predicted * worker->num_requests); + fprintf(fp, "\tcalculated (counted) per request time = %" PRIu64 "\n", + worker->tracking.running / worker->num_requests); fr_time_tracking_debug(&worker->tracking, fp); diff --git a/src/main/cf_parse.c b/src/main/cf_parse.c index 20326f41799..40a869d3b2f 100644 --- a/src/main/cf_parse.c +++ b/src/main/cf_parse.c @@ -575,6 +575,7 @@ static int CC_HINT(nonnull(3,4)) cf_pair_parse_internal(TALLOC_CTX *ctx, void *o */ if (!out) { if (!rule->func) { + no_out: cf_log_err(cs, "Rule doesn't specify output destination"); return -1; } @@ -641,22 +642,35 @@ static int CC_HINT(nonnull(3,4)) cf_pair_parse_internal(TALLOC_CTX *ctx, void *o for (i = 0; i < count; i++, cp = cf_pair_find_next(cs, cp, rule->name)) { int ret; - cf_parse_t func = cf_pair_parse_value; + cf_parse_t func; void *entry; + TALLOC_CTX *value_ctx = array ? array : ctx; + /* + * Figure out where to write the output + */ + if (!array) { + entry = NULL; + } else if (FR_BASE_TYPE(type) == FR_TYPE_VOID) { + entry = &array[i]; + } else { + entry = ((uint8_t *) array) + i * fr_value_box_field_sizes[FR_BASE_TYPE(type)]; + } + + /* + * Switch between customer parsing function + * and the standard value parsing function. + */ if (rule->func) { cf_log_debug(cs, "%.*s%s = %s", PAIR_SPACE(cs), parse_spaces, cf_pair_attr(cp), cp->value); func = rule->func; - } - - if (FR_BASE_TYPE(type) == FR_TYPE_VOID) { - entry = &array[i]; } else { - entry = ((uint8_t *) array) + i * fr_value_box_field_sizes[FR_BASE_TYPE(type)]; + if (!entry) goto no_out; + func = cf_pair_parse_value; } - ret = func(array ? array : ctx, entry, cf_pair_to_item(cp), rule); + ret = func(value_ctx, entry, cf_pair_to_item(cp), rule); if (ret < 0) { talloc_free(array); talloc_free(dflt_cp); diff --git a/src/modules/proto_detail/proto_detail_work.c b/src/modules/proto_detail/proto_detail_work.c index 73795ac9bc3..8f6bdd41867 100644 --- a/src/modules/proto_detail/proto_detail_work.c +++ b/src/modules/proto_detail/proto_detail_work.c @@ -258,8 +258,8 @@ redo: * record, every line MUST have a leading tab. */ if (p[1] != '\t') { - ERROR("proto_detail (%s): Malformed line found at offset %zd in file %s", - inst->name, (size_t) (p - buffer) + inst->header_offset, + ERROR("proto_detail (%s): Malformed line found at offset %zu in file %s", + inst->name, (size_t)((p - buffer) + inst->header_offset), inst->filename_work); return -1; } @@ -300,9 +300,9 @@ redo: * this, it's malformed. */ if (memcmp(p, " = ", 3) != 0) { - ERROR("proto_detail (%s): Malformed line found at offset %zd: %.*s of file %s", + ERROR("proto_detail (%s): Malformed line found at offset %zu: %.*s of file %s", inst->name, - (size_t) (p - buffer) + inst->header_offset, (int) (end - p), p, + (size_t)((p - buffer) + inst->header_offset), (int) (end - p), p, inst->filename_work); return -1; } diff --git a/src/modules/rlm_mschap/opendir.c b/src/modules/rlm_mschap/opendir.c index b7af839e15c..b5145bdc9df 100644 --- a/src/modules/rlm_mschap/opendir.c +++ b/src/modules/rlm_mschap/opendir.c @@ -238,9 +238,9 @@ rlm_rcode_t od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge, VALUE_PAIR * tDataBuffer *pStepBuff = NULL; tDataNode *pAuthType = NULL; uint32_t uiCurr = 0; - uint32_t uiLen = 0; + uint32_t user_id_len = 0; char *username_string = NULL; - char *shortUserName = NULL; + char *short_user_name = NULL; VALUE_PAIR *response = fr_pair_find_by_num(request->packet->vps, VENDORPEC_MICROSOFT, FR_MSCHAP2_RESPONSE, TAG_ANY); #ifndef NDEBUG @@ -260,7 +260,7 @@ rlm_rcode_t od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge, VALUE_PAIR * return RLM_MODULE_FAIL; } - rcode = getUserNodeRef(request, username_string, &shortUserName, &userNodeRef, dsRef); + rcode = getUserNodeRef(request, username_string, &short_user_name, &userNodeRef, dsRef); if (rcode != RLM_MODULE_OK) { if (rcode != RLM_MODULE_NOOP) { RDEBUG2("od_mschap_auth: getUserNodeRef() failed"); @@ -299,14 +299,16 @@ rlm_rcode_t od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge, VALUE_PAIR * pAuthType = dsDataNodeAllocateString(dsRef, kDSStdAuthMSCHAP2); uiCurr = 0; - RDEBUG2("OD username_string = %s, OD shortUserName=%s (length = %lu)\n", username_string, shortUserName, strlen(shortUserName)); + user_id_len = (uint32_t)short_user_name ? strlen(short_user_name) : 0; + + RDEBUG2("OD username_string = %s, OD short_user_name=%s (length = %u)", + username_string, short_user_name, user_id_len); /* User name length + username */ - uiLen = (uint32_t)strlen(shortUserName); - memcpy(&(tDataBuff->fBufferData[uiCurr]), &uiLen, sizeof(uiLen)); - uiCurr += sizeof(uiLen); - memcpy(&(tDataBuff->fBufferData[uiCurr]), shortUserName, uiLen); - uiCurr += uiLen; + memcpy(&(tDataBuff->fBufferData[uiCurr]), &user_id_len, sizeof(user_id_len)); + uiCurr += sizeof(user_id_len); + memcpy(&(tDataBuff->fBufferData[uiCurr]), short_user_name, user_id_len); + uiCurr += user_id_len; #ifndef NDEBUG RINDENT(); RDEBUG2("Stepbuf server challenge : "); @@ -317,12 +319,12 @@ rlm_rcode_t od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge, VALUE_PAIR * #endif /* server challenge (ie. my (freeRADIUS) challenge) */ - uiLen = 16; - memcpy(&(tDataBuff->fBufferData[uiCurr]), &uiLen, sizeof(uiLen)); - uiCurr += sizeof(uiLen); + user_id_len = 16; + memcpy(&(tDataBuff->fBufferData[uiCurr]), &user_id_len, sizeof(user_id_len)); + uiCurr += sizeof(user_id_len); memcpy(&(tDataBuff->fBufferData[uiCurr]), &(challenge->vp_strvalue[0]), - uiLen); - uiCurr += uiLen; + user_id_len); + uiCurr += user_id_len; #ifndef NDEBUG RDEBUG2("Stepbuf peer challenge : "); @@ -333,12 +335,12 @@ rlm_rcode_t od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge, VALUE_PAIR * #endif /* peer challenge (ie. the client-generated response) */ - uiLen = 16; - memcpy(&(tDataBuff->fBufferData[uiCurr]), &uiLen, sizeof(uiLen)); - uiCurr += sizeof(uiLen); + user_id_len = 16; + memcpy(&(tDataBuff->fBufferData[uiCurr]), &user_id_len, sizeof(user_id_len)); + uiCurr += sizeof(user_id_len); memcpy(&(tDataBuff->fBufferData[uiCurr]), &(response->vp_strvalue[2]), - uiLen); - uiCurr += uiLen; + user_id_len); + uiCurr += user_id_len; #ifndef NDEBUG RDEBUG2("Stepbuf p24 : "); @@ -350,19 +352,19 @@ rlm_rcode_t od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge, VALUE_PAIR * #endif /* p24 (ie. second part of client-generated response) */ - uiLen = 24; /* strlen(&(response->vp_strvalue[26])); may contain NULL byte in the middle. */ - memcpy(&(tDataBuff->fBufferData[uiCurr]), &uiLen, sizeof(uiLen)); - uiCurr += sizeof(uiLen); + user_id_len = 24; /* strlen(&(response->vp_strvalue[26])); may contain NULL byte in the middle. */ + memcpy(&(tDataBuff->fBufferData[uiCurr]), &user_id_len, sizeof(user_id_len)); + uiCurr += sizeof(user_id_len); memcpy(&(tDataBuff->fBufferData[uiCurr]), &(response->vp_strvalue[26]), - uiLen); - uiCurr += uiLen; + user_id_len); + uiCurr += user_id_len; /* Client generated use name (short name?) */ - uiLen = (uint32_t)strlen(username_string); - memcpy(&(tDataBuff->fBufferData[uiCurr]), &uiLen, sizeof(uiLen)); - uiCurr += sizeof(uiLen); - memcpy(&(tDataBuff->fBufferData[uiCurr]), username_string, uiLen); - uiCurr += uiLen; + user_id_len = (uint32_t)strlen(username_string); + memcpy(&(tDataBuff->fBufferData[uiCurr]), &user_id_len, sizeof(user_id_len)); + uiCurr += sizeof(user_id_len); + memcpy(&(tDataBuff->fBufferData[uiCurr]), username_string, user_id_len); + uiCurr += user_id_len; tDataBuff->fBufferLength = uiCurr; @@ -391,8 +393,8 @@ rlm_rcode_t od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge, VALUE_PAIR * /* clean up */ if (username_string != NULL) talloc_free(username_string); - if (shortUserName != NULL) - talloc_free(shortUserName); + if (short_user_name != NULL) + talloc_free(short_user_name); if (tDataBuff != NULL) dsDataBufferDeAllocate(dsRef, tDataBuff);