Skip to content

Commit 8ff96b5

Browse files
pflnashif
authored andcommitted
drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable. MISRA-C rule 7.2 Signed-off-by: Patrik Flykt <[email protected]>
1 parent 25e8e4d commit 8ff96b5

File tree

172 files changed

+693
-693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+693
-693
lines changed

drivers/adc/adc_context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static inline void adc_context_start_read(struct adc_context *ctx,
185185
ctx->status = 0;
186186

187187
if (ctx->sequence->options) {
188-
ctx->sampling_index = 0;
188+
ctx->sampling_index = 0U;
189189

190190
if (ctx->sequence->options->interval_us != 0) {
191191
atomic_set(&ctx->sampling_requested, 0);

drivers/adc/adc_dw.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static int adc_dw_read_request(struct device *dev,
294294
if (seq_tbl->options) {
295295
info->seq_size = seq_tbl->options->extra_samplings + 1;
296296
} else {
297-
info->seq_size = 1;
297+
info->seq_size = 1U;
298298
}
299299

300300
info->state = ADC_STATE_SAMPLING;
@@ -342,7 +342,7 @@ static void adc_dw_start_conversion(struct device *dev)
342342
const struct adc_config *config = info->dev->config->config_info;
343343
const struct adc_sequence *entry = info->ctx.sequence;
344344
u32_t adc_base = config->reg_base;
345-
u32_t ctrl, tmp_val, interval_us = 0;
345+
u32_t ctrl, tmp_val, interval_us = 0U;
346346

347347
info->channel_id = find_lsb_set(info->channels) - 1;
348348

drivers/adc/adc_intel_quark_d2000.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static int adc_quark_d2000_read_request(struct device *dev,
267267
if (seq_tbl->options) {
268268
info->seq_size = seq_tbl->options->extra_samplings + 1;
269269
} else {
270-
info->seq_size = 1;
270+
info->seq_size = 1U;
271271
}
272272

273273
if (info->seq_size > ADC_FIFO_LEN) {
@@ -276,7 +276,7 @@ static int adc_quark_d2000_read_request(struct device *dev,
276276

277277
/* check if buffer has enough size */
278278
utmp = info->channels;
279-
num_channels = 0;
279+
num_channels = 0U;
280280
while (utmp) {
281281
if (utmp & BIT(0)) {
282282
num_channels++;
@@ -325,8 +325,8 @@ static void adc_quark_d2000_start_conversion(struct device *dev)
325325
info->dev->config->config_info;
326326
const struct adc_sequence *entry = info->ctx.sequence;
327327
volatile adc_reg_t *adc_regs = config->reg_base;
328-
u32_t i, val, interval_us = 0;
329-
u32_t idx = 0, offset = 0;
328+
u32_t i, val, interval_us = 0U;
329+
u32_t idx = 0U, offset = 0U;
330330

331331
info->channel_id = find_lsb_set(info->channels) - 1;
332332

@@ -338,7 +338,7 @@ static void adc_quark_d2000_start_conversion(struct device *dev)
338338
adc_regs->sample = ADC_FIFO_CLEAR;
339339

340340
/* setup the sequence table */
341-
for (i = 0; i < info->seq_size; i++) {
341+
for (i = 0U; i < info->seq_size; i++) {
342342
idx = i / 4;
343343
offset = (i % 4) * 8;
344344

drivers/adc/adc_mcux_adc16.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static void mcux_adc16_start_channel(struct device *dev)
133133
struct mcux_adc16_data *data = dev->driver_data;
134134

135135
adc16_channel_config_t channel_config;
136-
u32_t channel_group = 0;
136+
u32_t channel_group = 0U;
137137

138138
data->channel_id = find_lsb_set(data->channels) - 1;
139139

@@ -174,7 +174,7 @@ static void mcux_adc16_isr(void *arg)
174174
const struct mcux_adc16_config *config = dev->config->config_info;
175175
struct mcux_adc16_data *data = dev->driver_data;
176176
ADC_Type *base = config->base;
177-
u32_t channel_group = 0;
177+
u32_t channel_group = 0U;
178178
u16_t result;
179179

180180
result = ADC16_GetChannelConversionValue(base, channel_group);

drivers/adc/adc_nrfx_adc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence)
173173
return -EINVAL;
174174
}
175175

176-
active_channels = 0;
176+
active_channels = 0U;
177177
nrfx_adc_all_channels_disable();
178178

179179
/* Enable the channels selected for the pointed sequence.
180180
*/
181-
channel_id = 0;
181+
channel_id = 0U;
182182
while (selected_channels) {
183183
if (selected_channels & BIT(0)) {
184184
/* The nrfx driver requires setting the resolution

drivers/adc/adc_nrfx_saadc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence)
261261
return -EINVAL;
262262
}
263263

264-
active_channels = 0;
264+
active_channels = 0U;
265265

266266
/* Enable only the channels selected for the pointed sequence.
267267
* Disable all the rest.
268268
*/
269-
channel_id = 0;
269+
channel_id = 0U;
270270
do {
271271
if (selected_channels & BIT(channel_id)) {
272272
/* Signal an error if a selected channel has not been

drivers/adc/adc_sam_afec.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence)
187187
int error = 0;
188188
u32_t channels = sequence->channels;
189189

190-
data->channels = 0;
190+
data->channels = 0U;
191191

192192
/* Signal an error if the channel selection is invalid (no channels or
193193
* a non-existing one is selected).
@@ -212,8 +212,8 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence)
212212
return -EINVAL;
213213
}
214214

215-
u8_t num_active_channels = 0;
216-
u8_t channel = 0;
215+
u8_t num_active_channels = 0U;
216+
u8_t channel = 0U;
217217

218218
while (channels > 0) {
219219
if (channels & 1) {

drivers/aio/aio_comparator_qmsi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int aio_qmsi_cmp_init(struct device *dev)
142142
config.cmp_en = QM_SCSS_CMP->cmp_en;
143143

144144
/* Clear callback pointers */
145-
for (i = 0; i < dev_data->num_cmp; i++) {
145+
for (i = 0U; i < dev_data->num_cmp; i++) {
146146
dev_data->cb[i].cb = NULL;
147147
dev_data->cb[i].param = NULL;
148148
}
@@ -161,7 +161,7 @@ static void aio_qmsi_cmp_isr(void *data)
161161

162162
u32_t int_status = QM_SCSS_CMP->cmp_stat_clr;
163163

164-
for (i = 0; i < dev_data->num_cmp; i++) {
164+
for (i = 0U; i < dev_data->num_cmp; i++) {
165165
if (int_status & (1 << i)) {
166166
if (dev_data->cb[i].cb != NULL) {
167167
dev_data->cb[i].cb(dev_data->cb[i].param);

drivers/audio/intel_dmic.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,14 @@ static int source_ipm_helper(struct pdm_chan_cfg *config, u32_t *source_mask,
652652
u8_t pdm_ix;
653653
u8_t chan_ix;
654654
enum pdm_lr lr;
655-
u16_t pdm_lr_mask = 0;
655+
u16_t pdm_lr_mask = 0U;
656656
int ipm = 0;
657657

658658
/* clear outputs */
659-
*source_mask = 0;
660-
*stereo_mask = 0;
661-
*swap_mask = 0;
662-
*controller_mask = 0;
659+
*source_mask = 0U;
660+
*stereo_mask = 0U;
661+
*swap_mask = 0U;
662+
*controller_mask = 0U;
663663

664664
/* Loop number of PDM controllers in the configuration. If mic A
665665
* or B is enabled then a pdm controller is marked as active. Also it
@@ -668,7 +668,7 @@ static int source_ipm_helper(struct pdm_chan_cfg *config, u32_t *source_mask,
668668
* swapped mono left. The function returns also in array source[] the
669669
* indice of enabled pdm controllers to be used for IPM configuration.
670670
*/
671-
for (chan_ix = 0; chan_ix < config->req_num_chan; chan_ix++) {
671+
for (chan_ix = 0U; chan_ix < config->req_num_chan; chan_ix++) {
672672

673673
dmic_parse_channel_map(config->req_chan_map_lo,
674674
config->req_chan_map_hi,

drivers/bluetooth/hci/h4.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ static inline void copy_hdr(struct net_buf *buf)
155155
static void reset_rx(void)
156156
{
157157
rx.type = H4_NONE;
158-
rx.remaining = 0;
158+
rx.remaining = 0U;
159159
rx.have_hdr = false;
160-
rx.hdr_len = 0;
160+
rx.hdr_len = 0U;
161161
rx.discardable = false;
162162
}
163163

drivers/bluetooth/hci/h5.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ static void h5_init(void)
711711

712712
h5.link_state = UNINIT;
713713
h5.rx_state = START;
714-
h5.tx_win = 4;
714+
h5.tx_win = 4U;
715715

716716
/* TX thread */
717717
k_fifo_init(&h5.tx_queue);

drivers/bluetooth/hci/spi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline void spi_dump_message(const u8_t *pre, u8_t *buf,
8383
u8_t i, c;
8484

8585
printk("%s (%d): ", pre, size);
86-
for (i = 0; i < size; i++) {
86+
for (i = 0U; i < size; i++) {
8787
c = buf[i];
8888
printk("%x ", c);
8989
if (c >= 31 && c <= 126) {
@@ -283,7 +283,7 @@ static void bt_spi_rx_thread(void)
283283
u8_t header_master[5] = { SPI_READ, 0x00, 0x00, 0x00, 0x00 };
284284
u8_t header_slave[5];
285285
struct bt_hci_acl_hdr acl_hdr;
286-
u8_t size = 0;
286+
u8_t size = 0U;
287287
int ret;
288288

289289
(void)memset(&txmsg, 0xFF, SPI_MAX_MSG_LEN);

drivers/can/stm32_can.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static int can_stm32_init(struct device *dev)
288288
data->filter_usage = (1ULL << CAN_MAX_NUMBER_OF_FILTES) - 1ULL;
289289
(void)memset(data->rx_response, 0,
290290
sizeof(void *) * CONFIG_CAN_MAX_FILTER);
291-
data->response_type = 0;
291+
data->response_type = 0U;
292292

293293
clock = device_get_binding(STM32_CLOCK_CONTROL_NAME);
294294
__ASSERT_NO_MSG(clock);
@@ -595,8 +595,8 @@ static inline int can_stm32_set_filter(const struct can_filter *filter,
595595
CAN_TypeDef *can,
596596
int *filter_index)
597597
{
598-
u32_t mask = 0;
599-
u32_t id = 0;
598+
u32_t mask = 0U;
599+
u32_t id = 0U;
600600
int filter_nr = 0;
601601
int filter_index_tmp = CAN_NO_FREE_FILTER;
602602
int bank_nr;

drivers/clock_control/beetle_clock_control.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static inline int beetle_clock_control_on(struct device *dev,
8484
struct arm_clock_control_t *beetle_cc =
8585
(struct arm_clock_control_t *)(sub_system);
8686

87-
u8_t bit = 0;
87+
u8_t bit = 0U;
8888

8989
switch (beetle_cc->bus) {
9090
case CMSDK_AHB:
@@ -108,7 +108,7 @@ static inline int beetle_clock_control_off(struct device *dev,
108108
struct arm_clock_control_t *beetle_cc =
109109
(struct arm_clock_control_t *)(sub_system);
110110

111-
u8_t bit = 0;
111+
u8_t bit = 0U;
112112

113113
switch (beetle_cc->bus) {
114114
case CMSDK_AHB:
@@ -154,7 +154,7 @@ static const struct clock_control_driver_api beetle_clock_control_api = {
154154
#ifdef CONFIG_CLOCK_CONTROL_BEETLE_ENABLE_PLL
155155
static u32_t beetle_round_freq(u32_t mainclk)
156156
{
157-
u32_t nc_mainclk = 0;
157+
u32_t nc_mainclk = 0U;
158158

159159
/*
160160
* Verify that the frequency is in the supported range otherwise
@@ -175,7 +175,7 @@ static u32_t beetle_round_freq(u32_t mainclk)
175175

176176
static u32_t beetle_get_prescaler(u32_t mainclk)
177177
{
178-
u32_t pre_mainclk = 0;
178+
u32_t pre_mainclk = 0U;
179179

180180
/*
181181
* Verify that the frequency is in the supported range otherwise

drivers/clock_control/nrf5_power_clock.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int _m16src_start(struct device *dev, clock_control_subsys_t sub_system)
4747
return -EAGAIN;
4848
}
4949

50-
m16src_grd = 1;
50+
m16src_grd = 1U;
5151

5252
irq_unlock(imask);
5353

@@ -87,7 +87,7 @@ static int _m16src_start(struct device *dev, clock_control_subsys_t sub_system)
8787
}
8888

8989
/* release resource guard */
90-
m16src_grd = 0;
90+
m16src_grd = 0U;
9191

9292
hf_already_started:
9393
/* rollover should not happen as start and stop shall be
@@ -130,7 +130,7 @@ static int _m16src_stop(struct device *dev, clock_control_subsys_t sub_system)
130130
return -EAGAIN;
131131
}
132132

133-
m16src_grd = 1;
133+
m16src_grd = 1U;
134134

135135
irq_unlock(imask);
136136

@@ -139,7 +139,7 @@ static int _m16src_stop(struct device *dev, clock_control_subsys_t sub_system)
139139
nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTOP);
140140

141141
/* release resource guard */
142-
m16src_grd = 0;
142+
m16src_grd = 0U;
143143

144144
return 0;
145145
}
@@ -172,7 +172,7 @@ static int _k32src_start(struct device *dev, clock_control_subsys_t sub_system)
172172
goto lf_already_started;
173173
}
174174

175-
k32src_initialized = 1;
175+
k32src_initialized = 1U;
176176

177177
irq_unlock(imask);
178178

@@ -348,7 +348,7 @@ static void _power_clock_isr(void *arg)
348348
/* Start HF Clock if LF RC is used. */
349349
if ((NRF_CLOCK->LFCLKSRCCOPY & CLOCK_LFCLKSRCCOPY_SRC_Msk) ==
350350
CLOCK_LFCLKSRCCOPY_SRC_RC) {
351-
ctto = 1;
351+
ctto = 1U;
352352
}
353353
}
354354
}

drivers/console/ipm_console_receiver.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void ipm_console_thread(void *arg1, void *arg2, void *arg3)
3030
driver_data = d->driver_data;
3131
config_info = d->config->config_info;
3232
ARG_UNUSED(arg2);
33-
size32 = 0;
33+
size32 = 0U;
3434
pos = 0;
3535

3636
while (1) {
@@ -42,7 +42,7 @@ static void ipm_console_thread(void *arg1, void *arg2, void *arg3)
4242
if (ret) {
4343
/* Shouldn't ever happen... */
4444
printk("ipm console ring buffer error: %d\n", ret);
45-
size32 = 0;
45+
size32 = 0U;
4646
continue;
4747
}
4848

0 commit comments

Comments
 (0)