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,12 +6,13 @@
#include <hypervisor.h>
static int charout(int cmd, const char *s, int sz, void *hnd)
static int charout(int cmd, const char *s, int32_t sz_arg, void *hnd)
{
/* pointer to an integer to store the number of characters */
int *nchars = (int *)hnd;
/* working pointer */
const char *p = s;
int32_t sz = sz_arg;
/* copy mode ? */
if (cmd == PRINT_CMD_COPY) {

View File

@@ -16,9 +16,10 @@ static inline bool sbuf_is_empty(struct shared_buf *sbuf)
return (sbuf->head == sbuf->tail);
}
static inline uint32_t sbuf_next_ptr(uint32_t pos,
static inline uint32_t sbuf_next_ptr(uint32_t pos_arg,
uint32_t span, uint32_t scope)
{
uint32_t pos = pos_arg;
pos += span;
pos = (pos >= scope) ? (pos - scope) : pos;
return pos;

View File

@@ -237,13 +237,14 @@ exit:
return ((status > 0) ? (int)(ch) : SERIAL_EOF);
}
int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length)
int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length_arg)
{
char *data_read = buffer;
int c;
struct uart *port;
uint32_t index;
int status = 0;
uint32_t length = length_arg;
if ((buffer == NULL) || (length == 0U)) {
return 0;
@@ -316,12 +317,13 @@ static int serial_putc(uint32_t uart_handle, int c)
return ((bytes_written > 0U) ? c : (SERIAL_EOF));
}
int serial_puts(uint32_t uart_handle, const char *s, uint32_t length)
int serial_puts(uint32_t uart_handle, const char *s, uint32_t length_arg)
{
const char *old_data = s;
uint32_t index;
struct uart *port;
int retval = 0;
uint32_t length = length_arg;
if ((s == NULL) || (length == 0U)) {
return 0;

View File

@@ -177,8 +177,8 @@ extern struct tgt_uart Tgt_Uarts[SERIAL_MAX_DEVS];
uint32_t serial_open(const char *uart_id);
int serial_getc(uint32_t uart_handle);
int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length);
int serial_puts(uint32_t uart_handle, const char *s, uint32_t length);
int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length_arg);
int serial_puts(uint32_t uart_handle, const char *s, uint32_t length_arg);
uint32_t serial_get_rx_data(uint32_t uart_handle);
#endif /* !SERIAL_INTER_H */

View File

@@ -85,8 +85,9 @@ static void uart16550_enable(__unused struct tgt_uart *tgt_uart)
}
static void uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
uint32_t ref_freq, uint32_t *baud_div_ptr, uint32_t baud_rate)
uint32_t ref_freq, uint32_t *baud_div_ptr, uint32_t baud_rate_arg)
{
uint32_t baud_rate = baud_rate_arg;
uint32_t baud_multiplier = baud_rate < BAUD_460800 ? 16 : 13;
if (baud_rate == 0) {