... detected by or confusing Coverity Scan.
These have been marked False Positive / Intentional earlier.
But long term the best fix is to simply clean out the dead code.
else
Bin[i / 2] |= n;
}
- /* FIXME: Coverity detects the below as dead code.
+
+#if HASHHEXLEN != (2*HASHLEN)
+ /*
Why? :: right here i == 32
which means the first step of the for loop makes i==16
and cannot be < HASHLEN (which is also 16)
+
+ But only guaranteed if HASHHEXLEN == 2*HASHLEN
+ This will ensure correct 0-ing of bins no matter what.
*/
for (i = i / 2; i < HASHLEN; i++) {
Bin[i] = '\0';
}
+#endif
}
/* calculate H(A1) as per spec */
char *
ConfigParser::Undo()
{
- LOCAL_ARRAY(char, undoToken, CONFIG_LINE_LIMIT);
+ static char undoToken[CONFIG_LINE_LIMIT];
if (!Undo_.empty()) {
- strncpy(undoToken, Undo_.front().c_str(), sizeof(undoToken));
+ xstrncpy(undoToken, Undo_.front().c_str(), sizeof(undoToken));
undoToken[sizeof(undoToken) - 1] = '\0';
if (!PreviewMode_)
Undo_.pop();
static FILE *wordFile = NULL;
char *t;
- LOCAL_ARRAY(char, buf, CONFIG_LINE_LIMIT);
+ static char buf[CONFIG_LINE_LIMIT];
if ((t = ConfigParser::Undo()))
return t;
}
/* fromFile */
- if (fgets(buf, CONFIG_LINE_LIMIT, wordFile) == NULL) {
+ if (fgets(buf, sizeof(buf), wordFile) == NULL) {
/* stop reading from file */
fclose(wordFile);
wordFile = NULL;
if (errorStr) {
if (PreviewMode_)
- strncpy(UnQuoted, SQUID_ERROR_TOKEN, sizeof(UnQuoted));
+ xstrncpy(UnQuoted, SQUID_ERROR_TOKEN, sizeof(UnQuoted));
else {
debugs(3, DBG_CRITICAL, "FATAL: " << errorStr << ": " << errorPos);
self_destruct();
entries.back().nocomment.push_back(buff);
}
break;
-
+#if 0
case sEXIT:
assert(0); /* should never get here */
break;
+#endif
}
}
fetch->state = DIGEST_READ_CBLOCK;
return hdr_size; /* Say how much data we read */
- } else {
- /* need more data, do we have space? */
+ }
- if (size >= SM_PAGE_SIZE) {
- peerDigestFetchAbort(fetch, buf, "stored header too big");
- return -1;
- } else {
- return 0; /* We need to read more to parse .. */
- }
+ /* need more data, do we have space? */
+ if (size >= SM_PAGE_SIZE) {
+ peerDigestFetchAbort(fetch, buf, "stored header too big");
+ return -1;
}
- fatal("peerDigestSwapInHeaders() - shouldn't get here!\n");
- return 0; /* keep gcc happy */
+ return 0; /* We need to read more to parse .. */
}
int
peerDigestFetchAbort(fetch, buf, "invalid digest cblock");
return -1;
}
- } else {
- /* need more data, do we have space? */
+ }
- if (size >= SM_PAGE_SIZE) {
- peerDigestFetchAbort(fetch, buf, "digest cblock too big");
- return -1;
- } else {
- return 0; /* We need more data */
- }
+ /* need more data, do we have space? */
+ if (size >= SM_PAGE_SIZE) {
+ peerDigestFetchAbort(fetch, buf, "digest cblock too big");
+ return -1;
}
- fatal("peerDigestSwapInCBlock(): shouldn't get here!\n");
- return 0; /* keep gcc happy */
+ return 0; /* We need more data */
}
int
assert(fetch->mask_offset == pd->cd->mask_size);
assert(peerDigestFetchedEnough(fetch, NULL, 0, "peerDigestSwapInMask"));
return -1; /* XXX! */
- } else {
- /* We always read everything, so return so */
- return size;
}
- fatal("peerDigestSwapInMask(): shouldn't get here!\n");
- return 0; /* keep gcc happy */
+ /* We always read everything, so return size */
+ return size;
}
static int
StoreEntry *entry = psstate->entry;
if (entry)
- debugs(44, 3, "peerPingTimeout: '" << psstate->url() << "'" );
+ debugs(44, 3, psstate->url());
if (!cbdataReferenceValid(psstate->callback_data)) {
/* request aborted */
- entry->ping_status = PING_DONE;
+ if (entry)
+ entry->ping_status = PING_DONE;
cbdataReferenceDone(psstate->callback_data);
delete psstate;
return;
void
dump_wccp2_service_info(StoreEntry * e, const char *label, void *)
{
- char comma;
-
struct wccp2_service_list_t *srv;
int flags;
srv = wccp2_service_list_head;
/* flags */
flags = ntohl(srv->info.service_flags);
+ bool comma = false;
if (flags != 0) {
- comma = 0;
storeAppendPrintf(e, " flags=");
if (flags & WCCP2_SERVICE_SRC_IP_HASH) {
- storeAppendPrintf(e, "%ssrc_ip_hash", comma ? "," : "");
- comma = 1;
+ storeAppendPrintf(e, "src_ip_hash");
+ comma = true;
}
if (flags & WCCP2_SERVICE_DST_IP_HASH) {
storeAppendPrintf(e, "%sdst_ip_hash", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_SRC_PORT_HASH) {
storeAppendPrintf(e, "%ssource_port_hash", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_DST_PORT_HASH) {
storeAppendPrintf(e, "%sdst_port_hash", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_PORTS_DEFINED) {
storeAppendPrintf(e, "%sports_defined", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_PORTS_SOURCE) {
storeAppendPrintf(e, "%sports_source", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_SRC_IP_ALT_HASH) {
storeAppendPrintf(e, "%ssrc_ip_alt_hash", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_DST_IP_ALT_HASH) {
storeAppendPrintf(e, "%ssrc_ip_alt_hash", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_SRC_PORT_ALT_HASH) {
storeAppendPrintf(e, "%ssrc_port_alt_hash", comma ? "," : "");
- comma = 1;
+ comma = true;
}
if (flags & WCCP2_SERVICE_DST_PORT_ALT_HASH) {
storeAppendPrintf(e, "%sdst_port_alt_hash", comma ? "," : "");
- comma = 1;
+ //comma = true; // uncomment if more options added
}
}
/* ports */
- comma = 0;
+ comma = false;
if (srv->info.port0 != 0) {
- storeAppendPrintf(e, "%s%d", comma ? "," : " ports=", ntohs(srv->info.port0));
- comma = 1;
+ storeAppendPrintf(e, " ports=%d", ntohs(srv->info.port0));
+ comma = true;
}
if (srv->info.port1 != 0) {
storeAppendPrintf(e, "%s%d", comma ? "," : "ports=", ntohs(srv->info.port1));
- comma = 1;
+ comma = true;
}
if (srv->info.port2 != 0) {
storeAppendPrintf(e, "%s%d", comma ? "," : "ports=", ntohs(srv->info.port2));
- comma = 1;
+ comma = true;
}
if (srv->info.port3 != 0) {
storeAppendPrintf(e, "%s%d", comma ? "," : "ports=", ntohs(srv->info.port3));
- comma = 1;
+ comma = true;
}
if (srv->info.port4 != 0) {
storeAppendPrintf(e, "%s%d", comma ? "," : "ports=", ntohs(srv->info.port4));
- comma = 1;
+ comma = true;
}
if (srv->info.port5 != 0) {
storeAppendPrintf(e, "%s%d", comma ? "," : "ports=", ntohs(srv->info.port5));
- comma = 1;
+ comma = true;
}
if (srv->info.port6 != 0) {
storeAppendPrintf(e, "%s%d", comma ? "," : "ports=", ntohs(srv->info.port6));
- comma = 1;
+ comma = true;
}
if (srv->info.port7 != 0) {
storeAppendPrintf(e, "%s%d", comma ? "," : "ports=", ntohs(srv->info.port7));
- comma = 1;
+ // comma = true; // uncomment if more options are added
}
/* protocol */