hv: string: fix MISRA-C violations related to style
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>
This commit is contained in:
parent
2c6c383e54
commit
32d6aa97f9
|
@ -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 *memset(void *base, uint8_t v, size_t n);
|
||||||
void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen);
|
void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen);
|
||||||
int32_t atoi(const char *str);
|
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);
|
uint64_t strtoul_hex(const char *nptr);
|
||||||
char *strstr_s(const char *str1, size_t maxlen1,
|
char *strstr_s(const char *str1, size_t maxlen1,
|
||||||
const char *str2, size_t maxlen2);
|
const char *str2, size_t maxlen2);
|
||||||
|
|
|
@ -17,11 +17,11 @@ static inline bool is_space(char c)
|
||||||
static inline char hex_digit_value (char ch)
|
static inline char hex_digit_value (char ch)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
if ('0' <= ch && ch <= '9') {
|
if (('0' <= ch) && (ch <= '9')) {
|
||||||
c = ch - '0';
|
c = ch - '0';
|
||||||
} else if ('a' <= ch && ch <= 'f') {
|
} else if (('a' <= ch) && (ch <= 'f')) {
|
||||||
c = ch - 'a' + 10;
|
c = ch - 'a' + 10;
|
||||||
} else if ('A' <= ch && ch <= 'F') {
|
} else if (('A' <= ch) && (ch <= 'F')) {
|
||||||
c = ch - 'A' + 10;
|
c = ch - 'A' + 10;
|
||||||
} else {
|
} else {
|
||||||
c = -1;
|
c = -1;
|
||||||
|
@ -32,7 +32,7 @@ static inline char hex_digit_value (char ch)
|
||||||
/*
|
/*
|
||||||
* Convert a string to a long integer - decimal support only.
|
* 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;
|
const char *s = nptr;
|
||||||
char c;
|
char c;
|
||||||
|
@ -105,7 +105,7 @@ long strtol_deci(const char *nptr)
|
||||||
/* There is no overflow and no leading '-' exists. In such case
|
/* There is no overflow and no leading '-' exists. In such case
|
||||||
* acc already holds the right number. No action required. */
|
* acc already holds the right number. No action required. */
|
||||||
}
|
}
|
||||||
return (long)acc;
|
return (int64_t)acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue