Skip to content

Commit

Permalink
hv: string: fix MISRA-C violations related to style
Browse files Browse the repository at this point in the history
This patch fixes the MISRA-C violations in lib/string.c
 * add the required brackets for logical conjunctions
 * replace the basic type `long` with defined type `int64_t`

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
  • Loading branch information
shiqingg authored and wenlingz committed Dec 20, 2018
1 parent 2c6c383 commit 32d6aa9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hypervisor/include/lib/rtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ size_t strnlen_s(const char *str_arg, size_t maxlen_arg);
void *memset(void *base, uint8_t v, size_t n);
void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen);
int32_t atoi(const char *str);
long strtol_deci(const char *nptr);
int64_t strtol_deci(const char *nptr);
uint64_t strtoul_hex(const char *nptr);
char *strstr_s(const char *str1, size_t maxlen1,
const char *str2, size_t maxlen2);
Expand Down
10 changes: 5 additions & 5 deletions hypervisor/lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ static inline bool is_space(char c)
static inline char hex_digit_value (char ch)
{
char c;
if ('0' <= ch && ch <= '9') {
if (('0' <= ch) && (ch <= '9')) {
c = ch - '0';
} else if ('a' <= ch && ch <= 'f') {
} else if (('a' <= ch) && (ch <= 'f')) {
c = ch - 'a' + 10;
} else if ('A' <= ch && ch <= 'F') {
} else if (('A' <= ch) && (ch <= 'F')) {
c = ch - 'A' + 10;
} else {
c = -1;
Expand All @@ -32,7 +32,7 @@ static inline char hex_digit_value (char ch)
/*
* Convert a string to a long integer - decimal support only.
*/
long strtol_deci(const char *nptr)
int64_t strtol_deci(const char *nptr)
{
const char *s = nptr;
char c;
Expand Down Expand Up @@ -105,7 +105,7 @@ long strtol_deci(const char *nptr)
/* There is no overflow and no leading '-' exists. In such case
* acc already holds the right number. No action required. */
}
return (long)acc;
return (int64_t)acc;
}

/*
Expand Down

0 comments on commit 32d6aa9

Please sign in to comment.