From 7da9313107fbfc41f3eb86629a4590e7f6ccb66e Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周二, 05 3月 2013 21:43:34 +0800 Subject: [PATCH] Correct possible bugs (compiller warnings) --- libscpi/src/ieee488.c | 6 ++++-- libscpi/src/debug.c | 2 +- libscpi/src/utils.c | 18 +++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libscpi/src/debug.c b/libscpi/src/debug.c index 087fb1b..bec35e0 100644 --- a/libscpi/src/debug.c +++ b/libscpi/src/debug.c @@ -47,7 +47,7 @@ printf("**DEBUG: %s (\"", context->paramlist.cmd->pattern); res = fwrite(context->paramlist.parameters, 1, context->paramlist.length, stdout); (void)res; - printf("\" - %ld)\r\n", context->paramlist.length); + printf("\" - %ld\r\n", (uint32_t)context->paramlist.length); return TRUE; } diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index 513ed90..4b7cb67 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -64,8 +64,10 @@ static size_t writeControl(scpi_t * context, int ctrl, scpi_reg_val_t val) { if (context && context->interface && context->interface->control) { - context->interface->control(context, ctrl, val); - } + return context->interface->control(context, ctrl, val); + } else { + return 0; + } } /** diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c index 9f9e2e7..63051f5 100644 --- a/libscpi/src/utils.c +++ b/libscpi/src/utils.c @@ -163,7 +163,7 @@ for (i = 0; i < len1; i++) { - if ((strStart < 0) && isspace(str1[i])) { + if ((strStart < 0) && isspace((unsigned char)str1[i])) { continue; } @@ -186,15 +186,15 @@ break; } - if ((strStop >= 0) && quot && !isspace(str1[i])) { + if ((strStop >= 0) && quot && !isspace((unsigned char)str1[i])) { valid = 0; } - if (!quot && !isspace(str1[i]) && (str1[i] != ',')) { + if (!quot && !isspace((unsigned char)str1[i]) && (str1[i] != ',')) { strStop = i; } - if (isspace(str1[i])) { + if (isspace((unsigned char)str1[i])) { continue; } @@ -240,7 +240,7 @@ for (i = 0; i < len1; i++) { - if ((strStart < 0) && isspace(str1[i])) { + if ((strStart < 0) && isspace((unsigned char)str1[i])) { continue; } @@ -248,11 +248,11 @@ strStart = i; } - if (!isspace(str1[i]) && (str1[i] != ',')) { + if (!isspace((unsigned char)str1[i]) && (str1[i] != ',')) { strStop = i; } - if (isspace(str1[i])) { + if (isspace((unsigned char)str1[i])) { continue; } @@ -303,7 +303,7 @@ size_t skipWhitespace(const char * cmd, size_t len) { size_t i; for (i = 0; i < len; i++) { - if (!isspace(cmd[i])) { + if (!isspace((unsigned char)cmd[i])) { return i; } } @@ -321,7 +321,7 @@ size_t patternSeparatorShortPos(const char * pattern, size_t len) { size_t i; for (i = 0; (i < len) && pattern[i]; i++) { - if (islower(pattern[i])) { + if (islower((unsigned char)pattern[i])) { return i; } } -- Gitblit v1.9.1