Fix some cppcheck errors on lib/iscsi & lib/scsi. (#41)

Fixed error types:
 1 nullPointerRedundantCheck;
 2 unsignedLessThanZero;
 4 invalidPrintfArgType_sint;
 5 arrayIndexThenCheck
This commit is contained in:
liupan1111 2016-09-29 04:55:56 +08:00 committed by Daniel Verkamp
parent e445f16bac
commit 0bde77082d
5 changed files with 32 additions and 34 deletions

View File

@ -386,7 +386,6 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
SPDK_ERRLOG("iscsi_conn_params_init() failed\n"); SPDK_ERRLOG("iscsi_conn_params_init() failed\n");
error_return: error_return:
spdk_iscsi_param_free(conn->params); spdk_iscsi_param_free(conn->params);
if (conn)
free_conn(conn); free_conn(conn);
return -1; return -1;
} }

View File

@ -276,7 +276,6 @@ spdk_iscsi_config_dump_target_nodes(FILE *fp)
target->map[m].ig->tag); target->map[m].ig->tag);
} }
if (dev) {
const char *authmethod = "None"; const char *authmethod = "None";
char authgroup[32] = "None"; char authgroup[32] = "None";
const char *usedigest = "Auto"; const char *usedigest = "Auto";
@ -312,7 +311,6 @@ spdk_iscsi_config_dump_target_nodes(FILE *fp)
fprintf(fp, TARGET_NODE_QD_TMPL, fprintf(fp, TARGET_NODE_QD_TMPL,
target->queue_depth); target->queue_depth);
} }
}
} }
static void static void

View File

@ -66,7 +66,7 @@ int spdk_md5update(struct spdk_md5ctx *md5ctx, const void *data, size_t len)
if (md5ctx == NULL) if (md5ctx == NULL)
return -1; return -1;
if (data == NULL || len <= 0) if (data == NULL || len == 0)
return 0; return 0;
rc = MD5_Update(&md5ctx->md5ctx, data, len); rc = MD5_Update(&md5ctx->md5ctx, data, len);
return rc; return rc;

View File

@ -66,7 +66,8 @@ spdk_bdev_scsi_set_local_naa(char *name, uint8_t *buf)
{ {
int i, value, count = 0; int i, value, count = 0;
uint64_t naa, local_value; uint64_t naa, local_value;
for (i = 0; (name[i] != '\0') && (i < 16); i++) {
for (i = 0; (i < 16) && (name[i] != '\0'); i++) {
value = spdk_hex2bin(name[i]); value = spdk_hex2bin(name[i]);
if (i % 2) { if (i % 2) {
buf[count++] |= value << 4; buf[count++] |= value << 4;

View File

@ -440,7 +440,7 @@ performance_dump(int io_time)
target = head[index]; target = head[index];
if (target != NULL) { if (target != NULL) {
lcore_id = target->lcore; lcore_id = target->lcore;
printf("\r Logical core: %d\n", lcore_id); printf("\r Logical core: %u\n", lcore_id);
} }
while (target != NULL) { while (target != NULL) {
io_per_second = (float)target->io_completed / io_per_second = (float)target->io_completed /