device: avoid casting away const from config_info pointer

The driver-specific config_info structure referenced from the device
structure is marked const.  Some drivers fail to preserve that
qualifier when casting the pointer to the driver-specific structure,
violating MISRA 11.8.

Changes produced by scripts/coccinelle/const_config_info.cocci.

Some changes proposed by the script are not included because they
reveal mutation of state through the const pointer, though the
code works as long as the driver-specific object is defined without
the const qualifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-05-12 07:14:53 -05:00 committed by Carles Cufí
commit 4f16b419e8
18 changed files with 41 additions and 41 deletions

View file

@ -104,7 +104,7 @@ static inline void sleep(u32_t sleep_in_ms)
*******************************************/
void glcd_print(struct device *port, char *data, u32_t size)
{
const struct glcd_driver * const rom = (struct glcd_driver *)
const struct glcd_driver * const rom = (const struct glcd_driver *)
port->config_info;
struct glcd_data *dev = port->driver_data;
u8_t buf[] = { GLCD_CMD_SET_CGRAM_ADDR, 0 };
@ -119,7 +119,7 @@ void glcd_print(struct device *port, char *data, u32_t size)
void glcd_cursor_pos_set(struct device *port, u8_t col, u8_t row)
{
const struct glcd_driver * const rom = (struct glcd_driver *)
const struct glcd_driver * const rom = (const struct glcd_driver *)
port->config_info;
struct glcd_data *dev = port->driver_data;
@ -140,7 +140,7 @@ void glcd_cursor_pos_set(struct device *port, u8_t col, u8_t row)
void glcd_clear(struct device *port)
{
const struct glcd_driver * const rom = (struct glcd_driver *)
const struct glcd_driver * const rom = (const struct glcd_driver *)
port->config_info;
struct glcd_data *dev = port->driver_data;
u8_t clear[] = { 0, GLCD_CMD_SCREEN_CLEAR };
@ -153,7 +153,7 @@ void glcd_clear(struct device *port)
void glcd_display_state_set(struct device *port, u8_t opt)
{
const struct glcd_driver * const rom = (struct glcd_driver *)
const struct glcd_driver * const rom = (const struct glcd_driver *)
port->config_info;
struct glcd_data *dev = port->driver_data;
u8_t data[] = { 0, 0 };