HV:treewide:fix "Attempt to change parameter passed by value"

In the function scope,the parameter should not be
changed as Misra required.
V1->V2 recover some violations because of ldra's false positive.
V2->V3 sync local variable' type to parameter's type with the prefix of const.

Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Huihuang Shi
2018-07-25 11:19:52 +08:00
committed by lijinxia
parent e71a0887a0
commit 5189bcd272
26 changed files with 96 additions and 59 deletions

View File

@@ -6,10 +6,10 @@
#include <hv_lib.h>
static int do_udiv32(uint32_t dividend, uint32_t divisor,
static int do_udiv32(uint32_t dividend_arg, uint32_t divisor,
struct udiv_result *res)
{
uint32_t dividend = dividend_arg;
uint32_t mask;
/* dividend is always greater than or equal to the divisor. Neither
* divisor nor dividend are 0. Thus: * clz(dividend) and clz(divisor)
@@ -61,9 +61,10 @@ int udiv32(uint32_t dividend, uint32_t divisor, struct udiv_result *res)
return do_udiv32(dividend, divisor, res);
}
int udiv64(uint64_t dividend, uint64_t divisor, struct udiv_result *res)
int udiv64(uint64_t dividend_arg, uint64_t divisor_arg, struct udiv_result *res)
{
uint64_t dividend = dividend_arg;
uint64_t divisor = divisor_arg;
uint64_t mask;
uint64_t bits;

View File

@@ -6,8 +6,9 @@
#include <hv_lib.h>
void mdelay(uint32_t loop_count)
void mdelay(uint32_t loop_count_arg)
{
uint32_t loop_count = loop_count_arg;
/* Loop until done */
while (loop_count != 0U) {
/* Delay for 1 ms */

View File

@@ -351,11 +351,11 @@ void *memchr(const void *void_s, int c, size_t n)
* or else return null.
*
***********************************************************************/
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_arg)
{
uint8_t *dest8;
uint8_t *src8;
size_t slen = slen_arg;
if (slen == 0U || dmax == 0U || dmax < slen) {
ASSERT(false);

View File

@@ -682,10 +682,11 @@ static int charmem(int cmd, const char *s, int sz, void *hnd)
return n;
}
int vsnprintf(char *dst, int sz, const char *fmt, va_list args)
int vsnprintf(char *dst, int32_t sz_arg, const char *fmt, va_list args)
{
char c[1];
/* the result of this function */
int32_t sz = sz_arg;
int res = 0;
if (sz <= 0 || (dst == NULL)) {

View File

@@ -190,12 +190,13 @@ char *strchr(const char *s, int ch)
* 1) both d and s shall not be null pointers.
* 2) dmax shall not 0.
*/
char *strcpy_s(char *d, size_t dmax, const char *s)
char *strcpy_s(char *d, size_t dmax, const char *s_arg)
{
char *dest_base;
size_t dest_avail;
uint64_t overlap_guard;
const char *s = s_arg;
if (s == NULL || d == NULL || dmax == 0U) {
pr_err("%s: invalid src, dest buffer or length.", __func__);
@@ -266,11 +267,12 @@ char *strcpy_s(char *d, size_t dmax, const char *s)
* 3) will assert() if overlap happens or dest buffer has no
* enough space.
*/
char *strncpy_s(char *d, size_t dmax, const char *s, size_t slen)
char *strncpy_s(char *d, size_t dmax, const char *s, size_t slen_arg)
{
char *dest_base;
size_t dest_avail;
uint64_t overlap_guard;
size_t slen = slen_arg;
if (d == NULL || s == NULL) {
pr_err("%s: invlaid src or dest buffer", __func__);
@@ -343,9 +345,10 @@ char *strncpy_s(char *d, size_t dmax, const char *s, size_t slen)
* string length, excluding the null character.
* will return 0 if str is null.
*/
size_t strnlen_s(const char *str, size_t maxlen)
size_t strnlen_s(const char *str, size_t maxlen_arg)
{
size_t count;
size_t maxlen = maxlen_arg;
if (str == NULL) {
return 0;
@@ -384,8 +387,9 @@ int strcmp(const char *s1, const char *s2)
return *s1 - *s2;
}
int strncmp(const char *s1, const char *s2, size_t n)
int strncmp(const char *s1, const char *s2, size_t n_arg)
{
size_t n = n_arg;
while (((n - 1) != 0U) && ((*s1) != '\0') && ((*s2) != '\0')
&& ((*s1) == (*s2))) {
s1++;