Skip to content

Commit b74358d

Browse files
wuxyintellijinxia
authored andcommitted
HV:treewide:string assigned to const object
In the hypervisor, some strings are assigned to non const object, this violates MISRA C:2012. Update the type of the object as const type since it always points to string. Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
1 parent 6ca9971 commit b74358d

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static void cpu_set_logical_id(uint16_t pcpu_id)
823823

824824
static void print_hv_banner(void)
825825
{
826-
char *boot_msg = "ACRN Hypervisor\n\r";
826+
const char *boot_msg = "ACRN Hypervisor\n\r";
827827

828828
/* Print the boot message */
829829
printf(boot_msg);

hypervisor/boot/acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ probe_table(uint64_t address, const char *sig)
169169
return 1;
170170
}
171171

172-
void *get_acpi_tbl(char *sig)
172+
void *get_acpi_tbl(const char *sig)
173173
{
174174
struct acpi_table_rsdp *rsdp;
175175
struct acpi_table_rsdt *rsdt;

hypervisor/debug/dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint16_t pcpu_id)
228228
printf("\r\n");
229229
}
230230

231-
void __assert(uint32_t line, const char *file, char *txt)
231+
void __assert(uint32_t line, const char *file, const char *txt)
232232
{
233233
uint16_t pcpu_id = get_cpu_id();
234234
uint64_t rsp = cpu_rsp_get();

hypervisor/debug/serial.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
static struct uart *sio_ports[SERIAL_MAX_DEVS];
1111
static uint8_t sio_initialized[SERIAL_MAX_DEVS];
1212

13-
static struct uart *get_uart_by_id(char *uart_id, uint32_t *index)
13+
static struct uart *get_uart_by_id(const char *uart_id, uint32_t *index)
1414
{
1515
/* Initialize the index to the start of array. */
1616
*index = 0U;
@@ -78,7 +78,7 @@ int serial_init(void)
7878
return status;
7979
}
8080

81-
uint32_t serial_open(char *uart_id)
81+
uint32_t serial_open(const char *uart_id)
8282
{
8383
int status = SERIAL_DEV_NOT_FOUND;
8484
struct uart *uart;

hypervisor/debug/serial_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct uart {
175175
/* Null terminated array of target specific UART control blocks */
176176
extern struct tgt_uart Tgt_Uarts[SERIAL_MAX_DEVS];
177177

178-
uint32_t serial_open(char *uart_id);
178+
uint32_t serial_open(const char *uart_id);
179179
int serial_getc(uint32_t uart_handle);
180180
int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length);
181181
int serial_puts(uint32_t uart_handle, const char *s, uint32_t length);

hypervisor/debug/shell_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ uint8_t shell_getc_serial(struct shell *p_shell);
170170
void shell_special_serial(struct shell *p_shell, uint8_t ch);
171171
void kick_shell(struct shell *p_shell);
172172

173-
int shell_puts(struct shell *p_shell, char *str_ptr);
174-
int shell_set_name(struct shell *p_shell, char *name);
173+
int shell_puts(struct shell *p_shell, const char *str_ptr);
174+
int shell_set_name(struct shell *p_shell, const char *name);
175175
int shell_trigger_crash(struct shell *p_shell, int argc, char **argv);
176176

177177
#endif /* SHELL_INTER_H */

hypervisor/debug/shell_public.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int shell_init(void)
159159
return status;
160160
}
161161

162-
int shell_puts(struct shell *p_shell, char *str_ptr)
162+
int shell_puts(struct shell *p_shell, const char *str_ptr)
163163
{
164164
int status;
165165

@@ -178,7 +178,7 @@ int shell_puts(struct shell *p_shell, char *str_ptr)
178178
return status;
179179
}
180180

181-
int shell_set_name(struct shell *p_shell, char *name)
181+
int shell_set_name(struct shell *p_shell, const char *name)
182182
{
183183
int status;
184184

hypervisor/include/debug/assert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define ASSERT_H
99

1010
#ifdef HV_DEBUG
11-
void __assert(uint32_t line, const char *file, char *txt);
11+
void __assert(uint32_t line, const char *file, const char *txt);
1212

1313
#define ASSERT(x, ...) \
1414
if (!(x)) {\

0 commit comments

Comments
 (0)