From 24d71431e9c9da493ce00eb284ac9b0b2cb1bdca Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Tue, 26 Mar 2019 19:57:45 -0600 Subject: [PATCH] all: Add 'U' suffix when using unsigned variables Add a 'U' suffix to values when computing and comparing against unsigned variables. Signed-off-by: Patrik Flykt --- arch/arc/core/cache.c | 6 +- arch/arc/core/fault.c | 2 +- arch/arc/core/mpu/arc_mpu_v2_internal.h | 2 +- arch/arc/core/mpu/arc_mpu_v3_internal.h | 6 +- arch/arc/include/v2/cache.h | 2 +- .../core/cortex_m/mpu/arm_mpu_v7_internal.h | 8 +- .../core/cortex_m/mpu/arm_mpu_v8_internal.h | 6 +- arch/arm/core/cortex_m/mpu/nxp_mpu.c | 8 +- arch/arm/core/fault.c | 4 +- arch/arm/core/irq_offload.c | 2 +- arch/arm/core/thread.c | 2 +- arch/arm/include/cortex_m/exc.h | 2 +- arch/common/timing_info_bench.c | 4 +- arch/nios2/core/fatal.c | 2 +- arch/x86/core/cpuhalt.c | 2 +- arch/x86/core/fatal.c | 16 +- arch/x86/core/irq_manage.c | 4 +- arch/x86/core/spec_ctrl.c | 6 +- arch/x86/core/thread.c | 4 +- arch/x86/core/x86_mmu.c | 2 +- arch/x86_64/core/demo-kernel.c | 2 +- arch/x86_64/core/shared-page.h | 2 +- arch/x86_64/core/x86_64.c | 4 +- arch/x86_64/core/xuk-stub32.c | 2 +- arch/x86_64/core/xuk.c | 2 +- boards/posix/native_posix/irq_ctrl.c | 4 +- boards/posix/native_posix/native_rtc.c | 4 +- boards/posix/native_posix/timer_model.c | 8 +- boards/posix/nrf52_bsim/main.c | 2 +- drivers/adc/adc_context.h | 6 +- drivers/adc/adc_intel_quark_d2000.c | 6 +- drivers/adc/adc_intel_quark_se_c1000_ss.c | 6 +- drivers/adc/adc_nrfx_adc.c | 2 +- drivers/adc/adc_nrfx_saadc.c | 4 +- drivers/adc/adc_sam_afec.c | 14 +- drivers/audio/intel_dmic.c | 20 +- drivers/audio/mpxxdtyy-i2s.c | 2 +- drivers/audio/mpxxdtyy.c | 6 +- drivers/audio/tlv320dac310x.c | 6 +- drivers/bluetooth/hci/spi.c | 14 +- drivers/can/stm32_can.c | 4 +- drivers/console/uart_console.c | 8 +- drivers/counter/counter_mcux_rtc.c | 4 +- drivers/crypto/crypto_ataes132a.c | 36 +-- drivers/crypto/crypto_ataes132a_priv.h | 4 +- drivers/crypto/crypto_mtls_shim.c | 4 +- drivers/crypto/crypto_tc_shim.c | 4 +- drivers/display/display_ili9340.c | 6 +- drivers/display/display_mcux_elcdif.c | 4 +- drivers/display/display_sdl.c | 16 +- drivers/display/grove_lcd_rgb.c | 2 +- drivers/display/mb_display.c | 2 +- drivers/display/ssd1306.c | 4 +- drivers/display/ssd1673.c | 10 +- drivers/dma/dma_nios2_msgdma.c | 6 +- drivers/dma/dma_qmsi.c | 2 +- drivers/dma/dma_sam_xdmac.c | 8 +- drivers/dma/dma_stm32f4x.c | 4 +- drivers/entropy/entropy_nrf5.c | 4 +- drivers/ethernet/eth_dw.c | 2 +- drivers/ethernet/eth_sam_gmac.c | 44 +-- drivers/ethernet/eth_smsc911x.c | 52 ++-- drivers/ethernet/eth_stellaris.c | 10 +- drivers/ethernet/phy_sam_gmac.c | 6 +- drivers/flash/flash_gecko.c | 2 +- drivers/flash/flash_stm32f0x.c | 4 +- drivers/flash/flash_stm32f3x.c | 4 +- drivers/flash/flash_stm32f7x.c | 4 +- drivers/flash/flash_stm32l4x.c | 6 +- drivers/flash/soc_flash_nios2_qspi.c | 4 +- drivers/gpio/gpio_dw.c | 2 +- drivers/gpio/gpio_intel_apl.c | 8 +- drivers/gpio/gpio_mcux.c | 2 +- drivers/gpio/gpio_nrfx.c | 8 +- drivers/gpio/gpio_rv32m1.c | 10 +- drivers/gpio/gpio_sam0.c | 2 +- drivers/gpio/gpio_stm32.c | 2 +- drivers/i2c/i2c_dw.c | 16 +- drivers/i2c/i2c_esp32.c | 8 +- drivers/i2c/i2c_imx.c | 12 +- drivers/i2c/i2c_ll_stm32.c | 2 +- drivers/i2c/i2c_ll_stm32_v1.c | 12 +- drivers/i2c/i2c_ll_stm32_v2.c | 2 +- drivers/i2c/i2c_sam_twi.c | 6 +- drivers/i2c/i2c_sam_twihs.c | 6 +- drivers/i2c/i2c_sifive.c | 16 +- drivers/i2s/i2s_cavs.c | 8 +- drivers/i2s/i2s_ll_stm32.c | 10 +- drivers/i2s/i2s_sam_ssc.c | 22 +- drivers/ieee802154/ieee802154_cc1200.c | 16 +- drivers/ieee802154/ieee802154_cc2520.c | 12 +- drivers/ieee802154/ieee802154_kw41z.c | 12 +- drivers/ieee802154/ieee802154_mcr20a.c | 4 +- drivers/interrupt_controller/loapic_intr.c | 2 +- drivers/interrupt_controller/mvic.c | 2 +- drivers/interrupt_controller/plic.c | 2 +- drivers/interrupt_controller/shared_irq.c | 4 +- drivers/led/lp3943.c | 10 +- drivers/led/pca9633.c | 6 +- drivers/neural_net/intel_gna.c | 6 +- drivers/pci/pci.c | 4 +- drivers/pci/pci_config.c | 14 +- drivers/pci/pci_legacy_bridge.c | 12 +- drivers/pinmux/pinmux_esp32.c | 2 +- drivers/pinmux/pinmux_sam0.c | 4 +- drivers/pwm/pwm_dw.c | 6 +- drivers/pwm/pwm_imx.c | 4 +- drivers/pwm/pwm_mcux_ftm.c | 4 +- drivers/pwm/pwm_nrf5_sw.c | 8 +- drivers/pwm/pwm_nrfx.c | 10 +- drivers/pwm/pwm_pca9685.c | 2 +- drivers/pwm/pwm_qmsi.c | 8 +- drivers/pwm/pwm_sam.c | 2 +- drivers/pwm/pwm_sifive.c | 8 +- drivers/pwm/pwm_stm32.c | 4 +- drivers/sensor/adxl362/adxl362.c | 4 +- drivers/sensor/adxl372/adxl372.c | 6 +- drivers/sensor/bma280/bma280_trigger.c | 2 +- drivers/sensor/bme280/bme280.c | 8 +- drivers/sensor/bmg160/bmg160_trigger.c | 4 +- drivers/sensor/bmi160/bmi160.c | 6 +- drivers/sensor/ccs811/ccs811.c | 4 +- drivers/sensor/dht/dht.c | 2 +- drivers/sensor/fxas21002/fxas21002.c | 4 +- drivers/sensor/fxas21002/fxas21002_trigger.c | 2 +- drivers/sensor/fxos8700/fxos8700_trigger.c | 2 +- drivers/sensor/hp206c/hp206c.c | 2 +- drivers/sensor/isl29035/isl29035.c | 2 +- drivers/sensor/isl29035/isl29035_trigger.c | 2 +- drivers/sensor/lis2dh/lis2dh.c | 4 +- drivers/sensor/lis2ds12/lis2ds12_spi.c | 2 +- drivers/sensor/lis2dw12/lis2dw12.c | 12 +- drivers/sensor/lis2dw12/lis2dw12_spi.c | 2 +- drivers/sensor/lis2dw12/lis2dw12_trigger.c | 2 +- drivers/sensor/lis2mdl/lis2mdl.c | 2 +- drivers/sensor/lsm6dsl/lsm6dsl_shub.c | 4 +- drivers/sensor/lsm6dsl/lsm6dsl_spi.c | 2 +- drivers/sensor/max44009/max44009.c | 4 +- drivers/sensor/mcp9808/mcp9808.c | 2 +- drivers/sensor/mpu6050/mpu6050.c | 4 +- drivers/sensor/sht3xd/sht3xd.c | 2 +- drivers/sensor/sht3xd/sht3xd_trigger.c | 4 +- drivers/sensor/th02/th02.c | 4 +- drivers/serial/leuart_gecko.c | 6 +- drivers/serial/uart_cmsdk_apb.c | 2 +- drivers/serial/uart_gecko.c | 6 +- drivers/serial/uart_mcux.c | 4 +- drivers/serial/uart_mcux_lpsci.c | 4 +- drivers/serial/uart_mcux_lpuart.c | 4 +- drivers/serial/uart_ns16550.c | 2 +- drivers/serial/uart_pl011.c | 10 +- drivers/serial/uart_rv32m1_lpuart.c | 8 +- drivers/serial/uart_sam.c | 4 +- drivers/serial/uart_stellaris.c | 6 +- drivers/serial/usart_sam.c | 4 +- drivers/spi/spi_sam.c | 4 +- drivers/spi/spi_sam0.c | 10 +- drivers/timer/loapic_timer.c | 6 +- drivers/timer/sam0_rtc_timer.c | 6 +- drivers/usb/device/usb_dc_dw.c | 8 +- drivers/usb/device/usb_dc_kinetis.c | 8 +- drivers/usb/device/usb_dc_native_posix.c | 8 +- .../usb/device/usb_dc_native_posix_adapt.c | 6 +- drivers/usb/device/usb_dc_nrfx.c | 6 +- drivers/usb/device/usb_dc_sam.c | 10 +- drivers/usb/device/usb_dc_sam0.c | 14 +- drivers/usb/device/usb_dc_stm32.c | 2 +- drivers/watchdog/wdog_cmsdk_apb.c | 2 +- drivers/watchdog/wdt_esp32.c | 2 +- drivers/watchdog/wdt_mcux_wdog.c | 8 +- drivers/watchdog/wdt_nrfx.c | 8 +- drivers/watchdog/wdt_qmsi.c | 6 +- drivers/watchdog/wdt_sam.c | 6 +- drivers/watchdog/wdt_sam0.c | 8 +- drivers/wifi/eswifi/eswifi_bus_spi.c | 4 +- drivers/wifi/eswifi/eswifi_core.c | 2 +- drivers/wifi/simplelink/simplelink_sockets.c | 2 +- drivers/wifi/winc1500/wifi_winc1500.c | 2 +- .../winc1500/wifi_winc1500_nm_bus_wrapper.c | 2 +- include/arch/arc/v2/arcv2_irq_unit.h | 2 +- include/arch/arm/cortex_m/mpu/arm_mpu_v8m.h | 2 +- include/arch/x86/arch.h | 2 +- include/arch/x86/segmentation.h | 8 +- include/audio/dmic.h | 6 +- include/cmsis_rtos_v1/cmsis_os.h | 2 +- include/crypto/cipher.h | 6 +- include/i2c.h | 4 +- include/kernel.h | 4 +- include/logging/log_msg.h | 8 +- include/misc/sflist.h | 4 +- include/misc/stack.h | 2 +- include/net/buf.h | 4 +- include/net/net_context.h | 4 +- include/net/net_ip.h | 14 +- include/net/net_pkt.h | 2 +- include/net/trickle.h | 2 +- include/power.h | 2 +- include/ring_buffer.h | 2 +- include/rtc.h | 2 +- kernel/device.c | 2 +- kernel/include/ksched.h | 4 +- kernel/init.c | 6 +- kernel/int_latency_bench.c | 2 +- kernel/mailbox.c | 6 +- kernel/mem_domain.c | 10 +- kernel/mem_slab.c | 2 +- kernel/mutex.c | 4 +- kernel/pipes.c | 2 +- kernel/poll.c | 8 +- kernel/sched.c | 2 +- kernel/thread.c | 4 +- kernel/thread_abort.c | 2 +- kernel/timer.c | 12 +- kernel/userspace.c | 6 +- lib/cmsis_rtos_v1/cmsis_mailq.c | 6 +- lib/cmsis_rtos_v1/cmsis_msgq.c | 4 +- lib/cmsis_rtos_v1/cmsis_mutex.c | 2 +- lib/cmsis_rtos_v1/cmsis_semaphore.c | 2 +- lib/cmsis_rtos_v1/cmsis_signal.c | 2 +- lib/cmsis_rtos_v1/cmsis_thread.c | 2 +- lib/cmsis_rtos_v2/event_flags.c | 8 +- lib/cmsis_rtos_v2/mempool.c | 2 +- lib/cmsis_rtos_v2/msgq.c | 4 +- lib/cmsis_rtos_v2/mutex.c | 12 +- lib/cmsis_rtos_v2/semaphore.c | 2 +- lib/cmsis_rtos_v2/thread.c | 12 +- lib/cmsis_rtos_v2/thread_flags.c | 6 +- lib/gui/lvgl/lvgl_color_1.c | 2 +- lib/gui/lvgl/lvgl_fs.c | 6 +- lib/libc/minimal/source/stdout/prf.c | 10 +- lib/libc/minimal/source/string/string.c | 2 +- lib/os/base64.c | 8 +- lib/posix/mqueue.c | 4 +- lib/posix/pthread.c | 20 +- lib/posix/pthread_cond.c | 4 +- lib/posix/pthread_mutex.c | 8 +- lib/posix/pthread_rwlock.c | 4 +- lib/posix/timer.c | 2 +- .../code_relocation/src/main.c | 2 +- samples/basic/blink_led/src/main.c | 10 +- samples/basic/fade_led/src/main.c | 2 +- samples/basic/rgb_led/src/main.c | 2 +- samples/basic/servo_motor/src/main.c | 2 +- samples/bluetooth/central_hr/src/main.c | 4 +- samples/bluetooth/eddystone/src/main.c | 2 +- samples/bluetooth/gatt/hrs.c | 2 +- samples/bluetooth/hci_spi/src/main.c | 2 +- samples/bluetooth/mesh_demo/src/microbit.c | 4 +- samples/bluetooth/peripheral/src/main.c | 2 +- samples/bluetooth/peripheral_csc/src/main.c | 4 +- .../boards/96b_argonkey/microphone/src/main.c | 2 +- samples/boards/altera_max10/pio/src/main.c | 4 +- samples/boards/bbc_microbit/pong/src/ble.c | 6 +- samples/boards/bbc_microbit/sound/src/main.c | 6 +- .../boards/nrf52/mesh/onoff-app/src/main.c | 4 +- .../onoff_level_lighting_vnd_app/src/main.c | 2 +- .../src/mesh/device_composition.c | 46 +-- .../src/mesh/publisher.c | 8 +- .../src/mesh/state_binding.c | 10 +- .../src/mesh/transition.c | 52 ++-- .../boards/reel_board/mesh_badge/src/mesh.c | 2 +- .../reel_board/mesh_badge/src/reel_board.c | 6 +- samples/drivers/CAN/src/main.c | 14 +- samples/drivers/crypto/src/main.c | 6 +- samples/drivers/current_sensing/src/main.c | 12 +- samples/drivers/entropy/src/main.c | 2 +- samples/drivers/i2c_fujitsu_fram/src/main.c | 4 +- samples/drivers/i2c_scanner/src/main.c | 2 +- samples/drivers/lcd_hd44780/src/main.c | 8 +- samples/drivers/led_lp5562/src/main.c | 2 +- samples/drivers/rtc/src/main.c | 4 +- samples/drivers/spi_fujitsu_fram/src/main.c | 2 +- samples/drivers/watchdog/src/main.c | 4 +- samples/gui/lvgl/src/main.c | 6 +- samples/net/google_iot_mqtt/src/protocol.c | 12 +- samples/net/mqtt_publisher/src/main.c | 4 +- samples/net/promiscuous_mode/src/main.c | 2 +- samples/net/sockets/can/src/main.c | 2 +- .../net/sockets/coap_client/src/coap-client.c | 4 +- .../net/sockets/coap_server/src/coap-server.c | 2 +- samples/net/sockets/echo_client/src/tcp.c | 4 +- samples/net/sockets/echo_client/src/udp.c | 4 +- samples/net/sockets/echo_server/src/tcp.c | 2 +- samples/net/sockets/echo_server/src/udp.c | 2 +- samples/net/sockets/packet/src/packet.c | 2 +- samples/net/wpan_serial/src/main.c | 2 +- samples/net/zperf/src/shell_utils.c | 8 +- samples/net/zperf/src/zperf_shell.c | 12 +- samples/net/zperf/src/zperf_tcp_receiver.c | 4 +- samples/net/zperf/src/zperf_udp_receiver.c | 4 +- samples/net/zperf/src/zperf_udp_uploader.c | 4 +- .../timer_synchronization/src/main.c | 8 +- .../timer_synchronization/src/main.c | 4 +- samples/sensor/fxos8700-hid/src/main.c | 6 +- samples/subsys/ipc/openamp/remote/src/main.c | 2 +- samples/subsys/ipc/openamp/src/main.c | 2 +- samples/subsys/nvs/src/main.c | 10 +- .../shell/shell_module/src/dynamic_cmd.c | 2 +- samples/subsys/usb/hid-cdc/src/main.c | 24 +- samples/subsys/usb/hid-mouse/src/main.c | 10 +- samples/subsys/usb/webusb/src/main.c | 2 +- soc/arc/snps_arc_iot/sysconf.c | 2 +- soc/arm/atmel_sam/common/soc_gpio.c | 2 +- soc/riscv32/openisa_rv32m1/soc.c | 8 +- soc/riscv32/openisa_rv32m1/soc.h | 2 +- .../intel_quark/include/pinmux_quark_mcu.h | 2 +- soc/x86/intel_quark/quark_se/soc.c | 8 +- soc/xtensa/intel_s1000/soc.c | 4 +- subsys/bluetooth/controller/hci/hci.c | 34 +- subsys/bluetooth/controller/hci/hci_driver.c | 2 +- subsys/bluetooth/controller/ll_sw/ll_filter.c | 4 +- subsys/bluetooth/controller/ll_sw/ll_mesh.c | 4 +- subsys/bluetooth/controller/ll_sw/ll_test.c | 6 +- subsys/bluetooth/controller/ll_sw/lll.h | 4 +- subsys/bluetooth/controller/ll_sw/lll_chan.c | 28 +- .../controller/ll_sw/nordic/hal/nrf5/ecb.c | 2 +- .../ll_sw/nordic/hal/nrf5/radio/radio.c | 2 +- .../controller/ll_sw/nordic/lll/lll_adv.c | 6 +- .../controller/ll_sw/nordic/lll/lll_adv.h | 2 +- .../ll_sw/nordic/lll/lll_adv_internal.h | 6 +- .../controller/ll_sw/nordic/lll/lll_clock.c | 2 +- .../controller/ll_sw/nordic/lll/lll_conn.c | 43 +-- .../controller/ll_sw/nordic/lll/lll_filter.c | 66 ++-- .../controller/ll_sw/nordic/lll/lll_prof.c | 14 +- .../controller/ll_sw/nordic/lll/lll_scan.c | 28 +- .../controller/ll_sw/nordic/lll/lll_test.c | 14 +- subsys/bluetooth/controller/ll_sw/ull.c | 24 +- subsys/bluetooth/controller/ll_sw/ull_adv.c | 12 +- subsys/bluetooth/controller/ll_sw/ull_conn.c | 292 +++++++++--------- .../bluetooth/controller/ll_sw/ull_master.c | 66 ++-- subsys/bluetooth/controller/ll_sw/ull_scan.c | 20 +- subsys/bluetooth/controller/ll_sw/ull_slave.c | 26 +- subsys/bluetooth/controller/ticker/ticker.c | 38 +-- subsys/bluetooth/controller/util/mayfly.c | 22 +- subsys/bluetooth/controller/util/mfifo.h | 8 +- subsys/bluetooth/host/at.c | 4 +- subsys/bluetooth/host/avdtp.c | 2 +- subsys/bluetooth/host/conn.c | 2 +- subsys/bluetooth/host/gatt.c | 34 +- subsys/bluetooth/host/hci_core.c | 12 +- subsys/bluetooth/host/hci_ecc.c | 4 +- subsys/bluetooth/host/l2cap.c | 8 +- subsys/bluetooth/host/l2cap_br.c | 4 +- subsys/bluetooth/host/mesh/access.c | 10 +- subsys/bluetooth/host/mesh/adv.c | 4 +- subsys/bluetooth/host/mesh/cfg_cli.c | 6 +- subsys/bluetooth/host/mesh/cfg_srv.c | 74 ++--- subsys/bluetooth/host/mesh/friend.c | 14 +- subsys/bluetooth/host/mesh/health_cli.c | 2 +- subsys/bluetooth/host/mesh/health_srv.c | 8 +- subsys/bluetooth/host/mesh/main.c | 2 +- subsys/bluetooth/host/mesh/net.c | 16 +- subsys/bluetooth/host/mesh/prov.c | 6 +- subsys/bluetooth/host/mesh/settings.c | 24 +- subsys/bluetooth/host/mesh/shell.c | 4 +- subsys/bluetooth/host/mesh/transport.c | 8 +- subsys/bluetooth/host/rfcomm.c | 2 +- subsys/bluetooth/host/sdp.c | 36 +-- subsys/bluetooth/host/smp.c | 4 +- subsys/bluetooth/shell/bredr.c | 4 +- subsys/bluetooth/shell/bt.c | 4 +- subsys/bluetooth/shell/gatt.c | 10 +- subsys/bluetooth/shell/hci.c | 8 +- subsys/bluetooth/shell/l2cap.c | 4 +- subsys/bluetooth/shell/rfcomm.c | 2 +- subsys/console/tty.c | 16 +- subsys/cpp/cpp_ctors.c | 2 +- subsys/dfu/boot/mcuboot.c | 12 +- subsys/dfu/img_util/flash_img.c | 4 +- subsys/disk/disk_access_sdhc.c | 10 +- subsys/fb/cfb.c | 12 +- subsys/fs/fcb/fcb.c | 2 +- subsys/fs/fcb/fcb_getnext.c | 2 +- subsys/fs/fcb/fcb_priv.h | 4 +- subsys/fs/fcb/fcb_walk.c | 2 +- subsys/fs/nvs/nvs.c | 20 +- subsys/logging/log_backend_net.c | 4 +- subsys/logging/log_msg.c | 4 +- subsys/logging/log_output.c | 38 +-- subsys/mgmt/serial_util.c | 6 +- subsys/mgmt/smp.c | 2 +- subsys/net/buf.c | 8 +- subsys/net/ip/6lo.c | 102 +++--- subsys/net/ip/connection.c | 4 +- subsys/net/ip/dhcpv4.c | 52 ++-- subsys/net/ip/icmpv4.c | 6 +- subsys/net/ip/icmpv6.c | 6 +- subsys/net/ip/ipv4.c | 20 +- subsys/net/ip/ipv4_autoconf.c | 18 +- subsys/net/ip/ipv6.c | 18 +- subsys/net/ip/ipv6_fragment.c | 8 +- subsys/net/ip/ipv6_mld.c | 4 +- subsys/net/ip/ipv6_nbr.c | 31 +- subsys/net/ip/net_context.c | 6 +- subsys/net/ip/net_if.c | 4 +- subsys/net/ip/net_pkt.c | 16 +- subsys/net/ip/net_shell.c | 8 +- subsys/net/ip/route.c | 2 +- subsys/net/ip/tcp.c | 36 +-- subsys/net/ip/trickle.c | 6 +- subsys/net/ip/udp.c | 6 +- subsys/net/ip/utils.c | 16 +- subsys/net/l2/bluetooth/bluetooth.c | 4 +- subsys/net/l2/canbus/canbus.c | 4 +- subsys/net/l2/dummy/dummy.c | 4 +- subsys/net/l2/ethernet/ethernet.c | 4 +- subsys/net/l2/ethernet/gptp/gptp.c | 24 +- subsys/net/l2/ethernet/gptp/gptp_md.c | 40 +-- subsys/net/l2/ethernet/gptp/gptp_messages.c | 54 ++-- subsys/net/l2/ethernet/gptp/gptp_mi.c | 22 +- subsys/net/l2/ieee802154/ieee802154.c | 6 +- .../net/l2/ieee802154/ieee802154_fragment.c | 2 +- .../net/l2/ieee802154/ieee802154_fragment.h | 4 +- subsys/net/l2/ieee802154/ieee802154_frame.c | 12 +- subsys/net/l2/ieee802154/ieee802154_mgmt.c | 2 +- .../l2/ieee802154/ieee802154_radio_csma_ca.c | 2 +- .../l2/ieee802154/ieee802154_radio_utils.h | 2 +- .../net/l2/ieee802154/ieee802154_security.c | 4 +- subsys/net/l2/openthread/openthread_utils.c | 6 +- subsys/net/l2/wifi/wifi_mgmt.c | 4 +- subsys/net/l2/wifi/wifi_shell.c | 6 +- subsys/net/lib/coap/coap.c | 32 +- subsys/net/lib/coap/coap_link_format.c | 2 +- subsys/net/lib/dns/dns_pack.c | 8 +- subsys/net/lib/dns/llmnr_responder.c | 2 +- subsys/net/lib/dns/mdns_responder.c | 2 +- subsys/net/lib/dns/resolve.c | 8 +- subsys/net/lib/http/http_parser.c | 70 ++--- subsys/net/lib/http/http_parser_url.c | 12 +- subsys/net/lib/lwm2m/ipso_light_control.c | 2 +- subsys/net/lib/lwm2m/ipso_timer.c | 2 +- subsys/net/lib/lwm2m/lwm2m_engine.c | 76 ++--- subsys/net/lib/lwm2m/lwm2m_obj_device.c | 2 +- subsys/net/lib/lwm2m/lwm2m_obj_firmware.c | 4 +- subsys/net/lib/lwm2m/lwm2m_obj_security.c | 4 +- subsys/net/lib/lwm2m/lwm2m_rw_json.c | 24 +- subsys/net/lib/lwm2m/lwm2m_rw_oma_tlv.c | 18 +- subsys/net/lib/lwm2m/lwm2m_rw_plain_text.c | 6 +- subsys/net/lib/mqtt/mqtt.c | 10 +- subsys/net/lib/mqtt/mqtt_decoder.c | 2 +- subsys/net/lib/mqtt/mqtt_encoder.c | 6 +- subsys/net/lib/mqtt/mqtt_rx.c | 2 +- subsys/net/lib/sockets/sockets_select.c | 12 +- subsys/net/lib/sockets/sockets_tls.c | 6 +- subsys/net/lib/socks/socks.c | 2 +- subsys/settings/src/settings_fcb.c | 2 +- subsys/shell/modules/kernel_service.c | 4 +- subsys/shell/shell.c | 12 +- subsys/shell/shell_cmds.c | 6 +- subsys/shell/shell_help.c | 2 +- subsys/shell/shell_history.c | 6 +- subsys/shell/shell_ops.c | 10 +- subsys/shell/shell_uart.c | 2 +- subsys/shell/shell_utils.c | 8 +- subsys/testsuite/coverage/coverage.c | 16 +- subsys/testsuite/include/test_utils.h | 2 +- subsys/usb/bos.c | 2 +- subsys/usb/class/cdc_acm.c | 4 +- subsys/usb/class/hid/core.c | 18 +- subsys/usb/class/mass_storage.c | 8 +- subsys/usb/class/netusb/function_ecm.c | 2 +- subsys/usb/class/netusb/function_rndis.c | 2 +- subsys/usb/class/usb_dfu.c | 2 +- subsys/usb/usb_descriptor.c | 8 +- subsys/usb/usb_device.c | 8 +- tests/benchmarks/sched/src/main.c | 8 +- tests/benchmarks/sys_kernel/src/lifo.c | 2 +- tests/benchmarks/sys_kernel/src/mwfifo.c | 6 +- tests/benchmarks/sys_kernel/src/stack.c | 2 +- .../benchmarks/timing_info/src/yield_bench.c | 4 +- .../bsim_bt/bsim_test_app/src/test_connect1.c | 4 +- tests/bluetooth/tester/src/bttester.h | 4 +- tests/bluetooth/tester/src/gatt.c | 6 +- tests/bluetooth/tester/src/l2cap.c | 2 +- tests/boards/altera_max10/msgdma/src/dma.c | 10 +- tests/boards/intel_s1000_crb/src/dma_test.c | 12 +- tests/boards/intel_s1000_crb/src/spi_flash.c | 2 +- tests/boards/native_posix/rtc/src/main.c | 6 +- tests/cmsis_rtos_v1/src/timer.c | 4 +- tests/cmsis_rtos_v2/src/event_flags.c | 2 +- tests/cmsis_rtos_v2/src/kernel.c | 2 +- tests/cmsis_rtos_v2/src/thread_apis.c | 4 +- tests/cmsis_rtos_v2/src/timer.c | 8 +- tests/crypto/tinycrypt/src/ccm_mode.c | 6 +- tests/crypto/tinycrypt/src/ctr_prng.c | 2 +- tests/drivers/adc/adc_api/src/test_adc.c | 2 +- tests/drivers/can/api/src/main.c | 2 +- .../counter_basic_api/src/test_counter.c | 10 +- .../dma/chan_blen_transfer/src/test_dma.c | 10 +- tests/drivers/dma/loop_transfer/src/dma.c | 10 +- .../gpio/gpio_basic_api/src/test_pin_rw.c | 2 +- .../i2c/i2c_slave_api/common/i2c_virtual.c | 2 +- .../i2s/i2s_api/src/test_i2s_loopback.c | 8 +- .../drivers/i2s/i2s_api/src/test_i2s_states.c | 18 +- .../i2s/i2s_speed/src/test_i2s_speed.c | 8 +- .../rtc/rtc_basic_api/src/test_rtc_alarm.c | 4 +- tests/drivers/spi/spi_loopback/src/spi.c | 2 +- .../uart/uart_async_api/src/test_uart_async.c | 10 +- .../watchdog/wdt_basic_api/src/test_wdt.c | 18 +- .../boot_page_table/src/boot_page_table.c | 6 +- tests/kernel/common/src/intmath.c | 4 +- tests/kernel/early_sleep/src/main.c | 3 +- tests/kernel/fp_sharing/src/main.c | 6 +- tests/kernel/fp_sharing/src/pi.c | 2 +- .../mem_protect/mem_protect/src/kobject.c | 2 +- .../mem_protect/mem_protect/src/mem_domain.c | 2 +- .../mem_slab/mslab_api/src/test_mslab_api.c | 2 +- tests/kernel/poll/src/test_poll.c | 6 +- tests/kernel/semaphore/semaphore/src/main.c | 24 +- tests/kernel/timer/timer_monotonic/src/main.c | 2 +- tests/lib/c_lib/src/main.c | 2 +- tests/lib/ringbuffer/src/main.c | 10 +- tests/net/6lo/src/main.c | 4 +- tests/net/checksum_offload/src/main.c | 2 +- tests/net/context/src/main.c | 4 +- tests/net/ethernet_mgmt/src/main.c | 14 +- .../crypto/src/ieee802154_crypto_test.c | 16 +- tests/net/ieee802154/fragment/src/main.c | 4 +- .../l2/src/ieee802154_fake_driver.c | 4 +- tests/net/iface/src/main.c | 6 +- tests/net/ipv6/src/main.c | 28 +- tests/net/ipv6_fragment/src/main.c | 30 +- tests/net/lib/coap/src/main.c | 18 +- tests/net/lib/dns_resolve/src/main.c | 2 +- tests/net/lib/mqtt_packet/src/mqtt_packet.c | 2 +- .../mqtt_publisher/src/test_mqtt_publish.c | 4 +- .../lib/mqtt_pubsub/src/test_mqtt_pubsub.c | 8 +- .../mqtt_subscriber/src/test_mqtt_subscribe.c | 4 +- tests/net/mld/src/main.c | 2 +- tests/net/net_pkt/src/main.c | 4 +- tests/net/route/src/main.c | 2 +- tests/net/socket/poll/src/main.c | 2 +- tests/net/socket/select/src/main.c | 2 +- tests/net/tcp/src/main.c | 6 +- tests/net/traffic_class/src/main.c | 2 +- tests/net/tx_timestamp/src/main.c | 2 +- tests/net/vlan/src/main.c | 4 +- tests/posix/common/src/clock.c | 4 +- tests/posix/common/src/posix_rwlock.c | 2 +- tests/subsys/can/frame/src/main.c | 32 +- tests/subsys/fs/fcb/src/fcb_test_init.c | 4 +- tests/subsys/fs/fcb/src/fcb_test_last_of_n.c | 2 +- .../fs/fcb/src/fcb_test_multiple_scratch.c | 2 +- tests/subsys/fs/fcb/src/fcb_test_reset.c | 4 +- .../fs/nffs_fs_api/common/test_performance.c | 12 +- tests/subsys/jwt/src/jwt-test-private.c | 2 +- .../subsys/logging/log_msg/src/log_msg_test.c | 40 +-- .../logging/log_output/src/log_output_test.c | 2 +- .../fcb/src/settings_test_save_1_fcb.c | 4 +- .../fcb/src/settings_test_save_2_fcb.c | 4 +- .../fcb/src/settings_test_save_one_fcb.c | 4 +- .../fcb/src/settings_test_save_unaligned.c | 4 +- .../nffs/src/settings_test_compress_file.c | 2 +- .../nffs/src/settings_test_multiple_in_file.c | 4 +- .../nffs/src/settings_test_save_one_file.c | 4 +- .../nffs/src/settings_test_small_file.c | 4 +- tests/subsys/settings/src/settings_enc.c | 2 +- .../settings/src/settings_test_getset_int.c | 2 +- tests/unit/bluetooth/at/src/main.c | 2 +- 559 files changed, 2331 insertions(+), 2328 deletions(-) diff --git a/arch/arc/core/cache.c b/arch/arc/core/cache.c index 23914a57ff2..4e1a8af9dc2 100644 --- a/arch/arc/core/cache.c +++ b/arch/arc/core/cache.c @@ -91,7 +91,7 @@ static void dcache_flush_mlines(u32_t start_addr, u32_t size) u32_t end_addr; unsigned int key; - if (!dcache_available() || (size == 0)) { + if (!dcache_available() || (size == 0U)) { return; } @@ -150,9 +150,9 @@ static void init_dcache_line_size(void) u32_t val; val = z_arc_v2_aux_reg_read(_ARC_V2_D_CACHE_BUILD); - __ASSERT((val&0xff) != 0, "d-cache is not present"); + __ASSERT((val&0xff) != 0U, "d-cache is not present"); val = ((val>>16) & 0xf) + 1; - val *= 16; + val *= 16U; sys_cache_line_size = (size_t) val; } #endif diff --git a/arch/arc/core/fault.c b/arch/arc/core/fault.c index a43fd7edf34..9d0d5a648cc 100644 --- a/arch/arc/core/fault.c +++ b/arch/arc/core/fault.c @@ -77,7 +77,7 @@ void _Fault(NANO_ESF *esf) * stack check and mpu violation can come out together, then * parameter = 0x2 | [0x4 | 0x8 | 0x1] */ - if (vector == 6 && parameter & 0x2) { + if (vector == 6U && parameter & 0x2) { z_NanoFatalErrorHandler(_NANO_ERR_STACK_CHK_FAIL, esf); return; } diff --git a/arch/arc/core/mpu/arc_mpu_v2_internal.h b/arch/arc/core/mpu/arc_mpu_v2_internal.h index f7939811ccb..b6cce00799d 100644 --- a/arch/arc/core/mpu/arc_mpu_v2_internal.h +++ b/arch/arc/core/mpu/arc_mpu_v2_internal.h @@ -159,7 +159,7 @@ static inline int _mpu_configure(u8_t type, u32_t base, u32_t size) LOG_DBG("Region info: 0x%x 0x%x", base, size); - if (region_attr == 0 || region_index < 0) { + if (region_attr == 0U || region_index < 0) { return -EINVAL; } diff --git a/arch/arc/core/mpu/arc_mpu_v3_internal.h b/arch/arc/core/mpu/arc_mpu_v3_internal.h index 43366e8964a..ee652a87b66 100644 --- a/arch/arc/core/mpu/arc_mpu_v3_internal.h +++ b/arch/arc/core/mpu/arc_mpu_v3_internal.h @@ -320,7 +320,7 @@ static void _mpu_reset_dynamic_regions(void) _region_init(i, 0, 0, 0); } - for (i = 0; i < dynamic_regions_num; i++) { + for (i = 0U; i < dynamic_regions_num; i++) { _region_init( dyn_reg_info[i].index, dyn_reg_info[i].base, @@ -389,7 +389,7 @@ void arc_core_mpu_configure_thread(struct k_thread *thread) _mpu_reset_dynamic_regions(); #if defined(CONFIG_MPU_STACK_GUARD) #if defined(CONFIG_USERSPACE) - if ((thread->base.user_options & K_USER) != 0) { + if ((thread->base.user_options & K_USER) != 0U) { /* the areas before and after the user stack of thread is * kernel only. These area can be used as stack guard. * ----------------------- @@ -448,7 +448,7 @@ void arc_core_mpu_configure_thread(struct k_thread *thread) num_partitions = mem_domain->num_partitions; pparts = mem_domain->partitions; } else { - num_partitions = 0; + num_partitions = 0U; pparts = NULL; } diff --git a/arch/arc/include/v2/cache.h b/arch/arc/include/v2/cache.h index a6886d76f54..86139fdf797 100644 --- a/arch/arc/include/v2/cache.h +++ b/arch/arc/include/v2/cache.h @@ -44,7 +44,7 @@ static ALWAYS_INLINE void _icache_setup(void) val = z_arc_v2_aux_reg_read(_ARC_V2_I_CACHE_BUILD); val &= 0xff; - if (val != 0) { /* is i-cache present? */ + if (val != 0U) { /* is i-cache present? */ /* configure i-cache */ z_arc_v2_aux_reg_write(_ARC_V2_IC_CTRL, icache_config); } diff --git a/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h b/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h index b81131aa2dc..b2d57d21e84 100644 --- a/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h +++ b/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h @@ -52,11 +52,11 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part) * partition must align with size. */ int partition_is_valid = - ((part->size & (part->size - 1)) == 0) + ((part->size & (part->size - 1)) == 0U) && (part->size >= CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE) && - ((part->start & (part->size - 1)) == 0); + ((part->start & (part->size - 1)) == 0U); return partition_is_valid; } @@ -72,7 +72,7 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part) static inline u32_t _size_to_mpu_rasr_size(u32_t size) { /* The minimal supported region size is 32 bytes */ - if (size <= 32) { + if (size <= 32U) { return REGION_32B; } @@ -264,7 +264,7 @@ static int _mpu_configure_regions(const struct k_mem_partition int reg_index = start_reg_index; for (i = 0; i < regions_num; i++) { - if (regions[i]->size == 0) { + if (regions[i]->size == 0U) { continue; } /* Non-empty region. */ diff --git a/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h b/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h index 26dba595661..d98941a8745 100644 --- a/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h +++ b/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h @@ -101,7 +101,7 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part) == part->size) && ((part->start & - (CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0); + (CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0U); return partition_is_valid; } @@ -330,7 +330,7 @@ static int _mpu_configure_regions(const struct k_mem_partition int reg_index = start_reg_index; for (i = 0; i < regions_num; i++) { - if (regions[i]->size == 0) { + if (regions[i]->size == 0U) { continue; } /* Non-empty region. */ @@ -493,7 +493,7 @@ static int _mpu_mark_areas_for_dynamic_regions( * which dynamic memory regions may be programmed at run-time. */ for (int i = 0; i < dyn_region_areas_num; i++) { - if (dyn_region_areas[i].size == 0) { + if (dyn_region_areas[i].size == 0U) { continue; } /* Non-empty area */ diff --git a/arch/arm/core/cortex_m/mpu/nxp_mpu.c b/arch/arm/core/cortex_m/mpu/nxp_mpu.c index 63e15b3d8e9..e55466f6e8d 100644 --- a/arch/arm/core/cortex_m/mpu/nxp_mpu.c +++ b/arch/arm/core/cortex_m/mpu/nxp_mpu.c @@ -54,14 +54,14 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part) * minimum MPU region size. */ int partition_is_valid = - (part->size != 0) + (part->size != 0U) && ((part->size & (~(CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1))) == part->size) && ((part->start & - (CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0); + (CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0U); return partition_is_valid; } @@ -78,7 +78,7 @@ static void _region_init(const u32_t index, u32_t region_end = region_conf->end; u32_t region_attr = region_conf->attr.attr; - if (index == 0) { + if (index == 0U) { /* The MPU does not allow writes from the core to affect the * RGD0 start or end addresses nor the permissions associated * with the debugger; it can only write the permission fields @@ -241,7 +241,7 @@ static int _mpu_configure_regions(const struct k_mem_partition int reg_index = start_reg_index; for (i = 0; i < regions_num; i++) { - if (regions[i]->size == 0) { + if (regions[i]->size == 0U) { continue; } /* Non-empty region. */ diff --git a/arch/arm/core/fault.c b/arch/arm/core/fault.c index 6d2fc4ddd8d..19d73262d87 100644 --- a/arch/arm/core/fault.c +++ b/arch/arm/core/fault.c @@ -389,7 +389,7 @@ static int _BusFault(NANO_ESF *esf, int fromHardFault) if (sperr) { for (i = 0; i < SYSMPU_EAR_COUNT; i++, mask >>= 1) { - if ((sperr & mask) == 0) { + if ((sperr & mask) == 0U) { continue; } STORE_xFAR(edr, SYSMPU->SP[i].EDR); @@ -796,7 +796,7 @@ void _Fault(NANO_ESF *esf, u32_t exc_return) /* Invalid EXC_RETURN value */ goto _exit_fatal; } - if ((exc_return & EXC_RETURN_EXCEPTION_SECURE_Secure) == 0) { + if ((exc_return & EXC_RETURN_EXCEPTION_SECURE_Secure) == 0U) { /* Secure Firmware shall only handle Secure Exceptions. * This is a fatal error. */ diff --git a/arch/arm/core/irq_offload.c b/arch/arm/core/irq_offload.c index 9334a7cb564..d96cfd71fb0 100644 --- a/arch/arm/core/irq_offload.c +++ b/arch/arm/core/irq_offload.c @@ -29,7 +29,7 @@ void irq_offload(irq_offload_routine_t routine, void *parameter) unsigned int key; __asm__ volatile("mrs %0, PRIMASK;" : "=r" (key) : : "memory"); - __ASSERT(key == 0, "irq_offload called with interrupts locked\n"); + __ASSERT(key == 0U, "irq_offload called with interrupts locked\n"); #endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE && CONFIG_ASSERT */ k_sched_lock(); diff --git a/arch/arm/core/thread.c b/arch/arm/core/thread.c index a654f3eaab7..a4a8b350613 100644 --- a/arch/arm/core/thread.c +++ b/arch/arm/core/thread.c @@ -58,7 +58,7 @@ void z_new_thread(struct k_thread *thread, k_thread_stack_t *stack, char *pStackMem = K_THREAD_STACK_BUFFER(stack); char *stackEnd; /* Offset between the top of stack and the high end of stack area. */ - u32_t top_of_stack_offset = 0; + u32_t top_of_stack_offset = 0U; Z_ASSERT_VALID_PRIO(priority, pEntry); diff --git a/arch/arm/include/cortex_m/exc.h b/arch/arm/include/cortex_m/exc.h index e111974f037..9a18fbb738c 100644 --- a/arch/arm/include/cortex_m/exc.h +++ b/arch/arm/include/cortex_m/exc.h @@ -63,7 +63,7 @@ static ALWAYS_INLINE bool _IsInIsr(void) /* On ARMv6-M there is no nested execution bit, so we check * exception 3, hard fault, to a detect a nested exception. */ - || (vector == 3) + || (vector == 3U) #elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE) /* If not in thread mode, and if RETTOBASE bit in ICSR is 0, * then there are preempted active exceptions to execute. diff --git a/arch/common/timing_info_bench.c b/arch/common/timing_info_bench.c index cab2cc2adfe..471d4539fd6 100644 --- a/arch/common/timing_info_bench.c +++ b/arch/common/timing_info_bench.c @@ -80,7 +80,7 @@ u64_t __common_var_swap_end_time; void read_timer_start_of_swap(void) { - if (__read_swap_end_time_value == 1) { + if (__read_swap_end_time_value == 1U) { TIMING_INFO_PRE_READ(); __start_swap_time = (u32_t) TIMING_INFO_OS_GET_TIME(); } @@ -88,7 +88,7 @@ void read_timer_start_of_swap(void) void read_timer_end_of_swap(void) { - if (__read_swap_end_time_value == 1) { + if (__read_swap_end_time_value == 1U) { TIMING_INFO_PRE_READ(); __read_swap_end_time_value = 2U; __common_var_swap_end_time = (u64_t)TIMING_INFO_OS_GET_TIME(); diff --git a/arch/nios2/core/fatal.c b/arch/nios2/core/fatal.c index 66f968695ba..0b01d25b786 100644 --- a/arch/nios2/core/fatal.c +++ b/arch/nios2/core/fatal.c @@ -177,7 +177,7 @@ FUNC_NORETURN void _Fault(const NANO_ESF *esf) exc_reg = _nios2_creg_read(NIOS2_CR_EXCEPTION); /* Bit 31 indicates potentially fatal ECC error */ - eccftl = (exc_reg & NIOS2_EXCEPTION_REG_ECCFTL_MASK) != 0; + eccftl = (exc_reg & NIOS2_EXCEPTION_REG_ECCFTL_MASK) != 0U; /* Bits 2-6 contain the cause code */ cause = (exc_reg & NIOS2_EXCEPTION_REG_CAUSE_MASK) diff --git a/arch/x86/core/cpuhalt.c b/arch/x86/core/cpuhalt.c index 0713752e6b7..9361a589fa1 100644 --- a/arch/x86/core/cpuhalt.c +++ b/arch/x86/core/cpuhalt.c @@ -95,7 +95,7 @@ void k_cpu_atomic_idle(unsigned int key) "hlt\n\t"); /* restore interrupt lockout state before returning to caller */ - if ((key & 0x200U) == 0) { + if ((key & 0x200U) == 0U) { z_int_latency_start(); __asm__ volatile("cli"); } diff --git a/arch/x86/core/fatal.c b/arch/x86/core/fatal.c index 7b2531bee8e..a984d8c3172 100644 --- a/arch/x86/core/fatal.c +++ b/arch/x86/core/fatal.c @@ -47,7 +47,7 @@ static bool check_stack_bounds(u32_t addr, size_t size, u16_t cs) /* We were servicing an interrupt */ start = (u32_t)Z_ARCH_THREAD_STACK_BUFFER(_interrupt_stack); end = start + CONFIG_ISR_STACK_SIZE; - } else if ((cs & 0x3U) != 0 || + } else if ((cs & 0x3U) != 0U || (_current->base.user_options & K_USER) == 0) { /* Thread was in user mode, or is not a user mode thread. * The normal stack buffer is what we will check. @@ -79,13 +79,13 @@ static void unwind_stack(u32_t base_ptr, u16_t cs) struct stack_frame *frame; int i; - if (base_ptr == 0) { + if (base_ptr == 0U) { printk("NULL base ptr\n"); return; } for (i = 0; i < MAX_STACK_FRAMES; i++) { - if (base_ptr % sizeof(base_ptr) != 0) { + if (base_ptr % sizeof(base_ptr) != 0U) { printk("unaligned frame ptr\n"); return; } @@ -105,7 +105,7 @@ static void unwind_stack(u32_t base_ptr, u16_t cs) } #endif - if (frame->ret_addr == 0) { + if (frame->ret_addr == 0U) { break; } #ifdef CONFIG_X86_IAMCU @@ -372,9 +372,9 @@ static void dump_page_fault(NANO_ESF *esf) printk("***** CPU Page Fault (error code 0x%08x)\n", err); printk("%s thread %s address 0x%08x\n", - (err & US) != 0 ? "User" : "Supervisor", - (err & ID) != 0 ? "executed" : ((err & WR) != 0 ? "wrote" : - "read"), cr2); + (err & US) != 0U ? "User" : "Supervisor", + (err & ID) != 0U ? "executed" : ((err & WR) != 0U ? "wrote" : + "read"), cr2); #ifdef CONFIG_X86_MMU #ifdef CONFIG_X86_KPTI @@ -507,7 +507,7 @@ static FUNC_NORETURN __used void _df_handler_top(void) _main_tss.ss = DATA_SEG; _main_tss.eip = (u32_t)_df_handler_bottom; _main_tss.cr3 = (u32_t)&z_x86_kernel_pdpt; - _main_tss.eflags = 0; + _main_tss.eflags = 0U; /* NT bit is set in EFLAGS so we will task switch back to _main_tss * and run _df_handler_bottom diff --git a/arch/x86/core/irq_manage.c b/arch/x86/core/irq_manage.c index 2f6ebd55da3..ece128d50be 100644 --- a/arch/x86/core/irq_manage.c +++ b/arch/x86/core/irq_manage.c @@ -198,7 +198,7 @@ static unsigned int priority_to_free_vector(unsigned int requested_priority) z_interrupt_vectors_allocated[entry]; fsb = find_lsb_set(search_set); - __ASSERT(fsb != 0, "No remaning vectors for priority level %d", + __ASSERT(fsb != 0U, "No remaning vectors for priority level %d", requested_priority); /* @@ -314,7 +314,7 @@ int z_arch_irq_connect_dynamic(unsigned int irq, unsigned int priority, #else vector = priority_to_free_vector(priority); /* 0 indicates not used, vectors for interrupts start at 32 */ - __ASSERT(_irq_to_interrupt_vector[irq] == 0, + __ASSERT(_irq_to_interrupt_vector[irq] == 0U, "IRQ %d already configured", irq); _irq_to_interrupt_vector[irq] = vector; #endif diff --git a/arch/x86/core/spec_ctrl.c b/arch/x86/core/spec_ctrl.c index fdf70ad9810..55bb253e329 100644 --- a/arch/x86/core/spec_ctrl.c +++ b/arch/x86/core/spec_ctrl.c @@ -48,16 +48,16 @@ static int spec_ctrl_init(struct device *dev) u32_t cpuid7 = cpuid_extended_features(); #ifdef CONFIG_DISABLE_SSBD - if ((cpuid7 & CPUID_SPEC_CTRL_SSBD) != 0) { + if ((cpuid7 & CPUID_SPEC_CTRL_SSBD) != 0U) { enable_bits |= SPEC_CTRL_SSBD; } #endif #ifdef CONFIG_ENABLE_EXTENDED_IBRS - if ((cpuid7 & CPUID_SPEC_CTRL_IBRS) != 0) { + if ((cpuid7 & CPUID_SPEC_CTRL_IBRS) != 0U) { enable_bits |= SPEC_CTRL_IBRS; } #endif - if (enable_bits != 0) { + if (enable_bits != 0U) { u64_t cur = _x86_msr_read(IA32_SPEC_CTRL_MSR); _x86_msr_write(IA32_SPEC_CTRL_MSR, diff --git a/arch/x86/core/thread.c b/arch/x86/core/thread.c index 34507c87f59..e9aa90f717e 100644 --- a/arch/x86/core/thread.c +++ b/arch/x86/core/thread.c @@ -72,7 +72,7 @@ void z_new_thread(struct k_thread *thread, k_thread_stack_t *stack, _new_thread_init(thread, stack_buf, stack_size, priority, options); #if CONFIG_X86_USERSPACE - if ((options & K_USER) == 0) { + if ((options & K_USER) == 0U) { /* Running in kernel mode, kernel stack region is also a guard * page */ z_x86_mmu_set_flags(&z_x86_kernel_pdpt, @@ -100,7 +100,7 @@ void z_new_thread(struct k_thread *thread, k_thread_stack_t *stack, /* initial EFLAGS; only modify IF and IOPL bits */ initial_frame->eflags = (EflagsGet() & ~EFLAGS_MASK) | EFLAGS_INITIAL; #ifdef CONFIG_X86_USERSPACE - if ((options & K_USER) != 0) { + if ((options & K_USER) != 0U) { #ifdef _THREAD_WRAPPER_REQUIRED initial_frame->edi = (u32_t)z_arch_user_mode_enter; initial_frame->thread_entry = _x86_thread_entry_wrapper; diff --git a/arch/x86/core/x86_mmu.c b/arch/x86/core/x86_mmu.c index 9052e39cd7e..0532ca00fe5 100644 --- a/arch/x86/core/x86_mmu.c +++ b/arch/x86/core/x86_mmu.c @@ -291,7 +291,7 @@ static inline void _x86_mem_domain_pages_update(struct k_mem_domain *mem_domain, /* Get the partition info */ partition = &mem_domain->partitions[partition_index]; - if (partition->size == 0) { + if (partition->size == 0U) { continue; } partitions_count++; diff --git a/arch/x86_64/core/demo-kernel.c b/arch/x86_64/core/demo-kernel.c index 0f335262510..9887caed40a 100644 --- a/arch/x86_64/core/demo-kernel.c +++ b/arch/x86_64/core/demo-kernel.c @@ -150,7 +150,7 @@ void _cpu_start(int cpu) * "timer" API */ xuk_set_isr(INT_APIC_LVT_TIMER, 10, handler_timer, 0); - _apic.INIT_COUNT = 5000000; + _apic.INIT_COUNT = 5000000U; test_timers(); if (cpu == 0) { diff --git a/arch/x86_64/core/shared-page.h b/arch/x86_64/core/shared-page.h index fad0e1346df..40b882b8858 100644 --- a/arch/x86_64/core/shared-page.h +++ b/arch/x86_64/core/shared-page.h @@ -73,7 +73,7 @@ static inline void *alloc_page(int clear) { int *p = (int *)(long)_shared.next_page; - _shared.next_page += 4096; + _shared.next_page += 4096U; for (int i = 0; clear && i < 1024; i++) { p[i] = 0; diff --git a/arch/x86_64/core/x86_64.c b/arch/x86_64/core/x86_64.c index 6b0eab244ca..8efdecc5cae 100644 --- a/arch/x86_64/core/x86_64.c +++ b/arch/x86_64/core/x86_64.c @@ -145,7 +145,7 @@ void _cpu_start(int cpu) /* Set up the timer ISR, but ensure the timer is disabled */ xuk_set_isr(INT_APIC_LVT_TIMER, 13, x86_apic_timer_isr, 0); - _apic.INIT_COUNT = 0; + _apic.INIT_COUNT = 0U; xuk_set_isr(XUK_INT_RAW_VECTOR(SCHED_IPI_VECTOR), -1, sched_ipi_handler, 0); @@ -189,7 +189,7 @@ int z_arch_irq_connect_dynamic(unsigned int irq, unsigned int priority, u32_t flags) { ARG_UNUSED(flags); - __ASSERT(priority >= 2 && priority <= 15, + __ASSERT(priority >= 2U && priority <= 15U, "APIC interrupt priority must be 2-15"); xuk_set_isr(irq, priority, (void *)routine, parameter); diff --git a/arch/x86_64/core/xuk-stub32.c b/arch/x86_64/core/xuk-stub32.c index 3c6b6cfc100..5790cc4bee3 100644 --- a/arch/x86_64/core/xuk-stub32.c +++ b/arch/x86_64/core/xuk-stub32.c @@ -106,7 +106,7 @@ void *init_page_tables(void) /* Each PDE filled with 2M supervisor pages */ for (int i = 0; i < 512; i++) { - if (!(gb == 0 && i == 0)) { + if (!(gb == 0U && i == 0)) { pde[i].addr = (gb << 30) | (i << 21); pde[i].present = 1; pde[i].writable = 1; diff --git a/arch/x86_64/core/xuk.c b/arch/x86_64/core/xuk.c index 20a1990b453..112efd7be9c 100644 --- a/arch/x86_64/core/xuk.c +++ b/arch/x86_64/core/xuk.c @@ -481,7 +481,7 @@ static void smp_init(void) * the page we allocated. */ _shared.smpinit_lock = 0; - _shared.smpinit_stack = 0; + _shared.smpinit_stack = 0U; _shared.num_active_cpus = 1; printf("Sending SIPI IPI\n"); diff --git a/boards/posix/native_posix/irq_ctrl.c b/boards/posix/native_posix/irq_ctrl.c index 9cdeb158ccf..ad310abd9ee 100644 --- a/boards/posix/native_posix/irq_ctrl.c +++ b/boards/posix/native_posix/irq_ctrl.c @@ -97,7 +97,7 @@ int hw_irq_ctrl_get_highest_prio_irq(void) int winner = -1; int winner_prio = 256; - while (irq_status != 0) { + while (irq_status != 0U) { int irq_nbr = find_lsb_set(irq_status) - 1; irq_status &= ~((u64_t) 1 << irq_nbr); @@ -123,7 +123,7 @@ u32_t hw_irq_ctrl_change_lock(u32_t new_lock) irqs_locked = new_lock; if ((previous_lock == true) && (new_lock == false)) { - if (irq_status != 0) { + if (irq_status != 0U) { posix_irq_handler_im_from_sw(); } } diff --git a/boards/posix/native_posix/native_rtc.c b/boards/posix/native_posix/native_rtc.c index 5259a030fa0..ff2dedb9b47 100644 --- a/boards/posix/native_posix/native_rtc.c +++ b/boards/posix/native_posix/native_rtc.c @@ -28,7 +28,7 @@ u64_t native_rtc_gettime_us(int clock_type) u64_t sec; hwtimer_get_pseudohost_rtc_time(&nsec, &sec); - return sec * 1000000UL + nsec / 1000; + return sec * 1000000UL + nsec / 1000U; } posix_print_error_and_exit("Unknown clock source %i\n", @@ -45,7 +45,7 @@ void native_rtc_gettime(int clock_type, u32_t *nsec, u64_t *sec) { if (clock_type == RTC_CLOCK_BOOT || clock_type == RTC_CLOCK_REALTIME) { u64_t us = native_rtc_gettime_us(clock_type); - *nsec = (us % 1000000UL) * 1000; + *nsec = (us % 1000000UL) * 1000U; *sec = us / 1000000UL; } else { /* RTC_CLOCK_PSEUDOHOSTREALTIME */ hwtimer_get_pseudohost_rtc_time(nsec, sec); diff --git a/boards/posix/native_posix/timer_model.c b/boards/posix/native_posix/timer_model.c index 0f127e1377b..a4e85de5083 100644 --- a/boards/posix/native_posix/timer_model.c +++ b/boards/posix/native_posix/timer_model.c @@ -50,9 +50,9 @@ static char *us_time_to_str(char *dest, u64_t time) unsigned int second; unsigned int us; - hour = (time / 3600 / 1000000) % 24; - minute = (time / 60 / 1000000) % 60; - second = (time / 1000000) % 60; + hour = (time / 3600U / 1000000U) % 24; + minute = (time / 60U / 1000000U) % 60; + second = (time / 1000000U) % 60; us = time % 1000000; sprintf(dest, "%02u:%02u:%02u.%06u", hour, minute, second, us); @@ -202,7 +202,7 @@ static void hwtimer_tick_timer_reached(void) us_time_to_str(rs, real_time - boot_time); printf("tick @%5llims: diff = expected_rt - real_time = " "%5lli = %s - %s\n", - hw_timer_tick_timer/1000, diff, es, rs); + hw_timer_tick_timer/1000U, diff, es, rs); #endif if (diff > 0) { /* we need to slow down */ diff --git a/boards/posix/nrf52_bsim/main.c b/boards/posix/nrf52_bsim/main.c index ff2b14e38f0..fcf64d4f875 100644 --- a/boards/posix/nrf52_bsim/main.c +++ b/boards/posix/nrf52_bsim/main.c @@ -40,7 +40,7 @@ uint8_t inner_main_clean_up(int exit_code) u8_t bst_result = bst_delete(); - if (bst_result != 0) { + if (bst_result != 0U) { bs_trace_raw_time(2, "main: The TESTCASE FAILED with return " "code %u\n", bst_result); } diff --git a/drivers/adc/adc_context.h b/drivers/adc/adc_context.h index 9ba1d175e6a..b4359ba86b8 100644 --- a/drivers/adc/adc_context.h +++ b/drivers/adc/adc_context.h @@ -187,7 +187,7 @@ static inline void adc_context_start_read(struct adc_context *ctx, if (ctx->sequence->options) { ctx->sampling_index = 0U; - if (ctx->sequence->options->interval_us != 0) { + if (ctx->sequence->options->interval_us != 0U) { atomic_set(&ctx->sampling_requested, 0); adc_context_enable_timer(ctx); return; @@ -244,7 +244,7 @@ static inline void adc_context_on_sampling_done(struct adc_context *ctx, * a zero interval or if the timer expired again while * the current sampling was in progress. */ - if (ctx->sequence->options->interval_us == 0) { + if (ctx->sequence->options->interval_us == 0U) { adc_context_start_sampling(ctx); } else if (atomic_dec(&ctx->sampling_requested) > 1) { adc_context_start_sampling(ctx); @@ -253,7 +253,7 @@ static inline void adc_context_on_sampling_done(struct adc_context *ctx, return; } - if (ctx->sequence->options->interval_us != 0) { + if (ctx->sequence->options->interval_us != 0U) { adc_context_disable_timer(ctx); } } diff --git a/drivers/adc/adc_intel_quark_d2000.c b/drivers/adc/adc_intel_quark_d2000.c index 27e10465a39..d48b164b35b 100644 --- a/drivers/adc/adc_intel_quark_d2000.c +++ b/drivers/adc/adc_intel_quark_d2000.c @@ -248,10 +248,10 @@ static int adc_quark_d2000_read_request(struct device *dev, case 8: case 10: case 12: - info->resolution = (seq_tbl->resolution / 2) - 3; + info->resolution = (seq_tbl->resolution / 2U) - 3; /* sampling window is (resolution + 2) cycles */ - info->sample_window = seq_tbl->resolution + 2; + info->sample_window = seq_tbl->resolution + 2U; break; default: return -EINVAL; @@ -267,7 +267,7 @@ static int adc_quark_d2000_read_request(struct device *dev, * System clock is 32MHz, which means 1us == 32 cycles * if divider is 1. */ - interval = seq_tbl->options->interval_us * 32 / + interval = seq_tbl->options->interval_us * 32U / CONFIG_ADC_INTEL_QUARK_D2000_CLOCK_RATIO; if (interval < info->sample_window) { diff --git a/drivers/adc/adc_intel_quark_se_c1000_ss.c b/drivers/adc/adc_intel_quark_se_c1000_ss.c index 4adf5fea55d..ffdd829d9a4 100644 --- a/drivers/adc/adc_intel_quark_se_c1000_ss.c +++ b/drivers/adc/adc_intel_quark_se_c1000_ss.c @@ -94,7 +94,7 @@ static inline void wait_slv0_bit_set(u32_t bit_mask) do { reg_value = sys_in32(PERIPH_ADDR_BASE_CREG_SLV0); - } while ((reg_value & bit_mask) == 0); + } while ((reg_value & bit_mask) == 0U); } static void set_power_mode_inner(u32_t mode) @@ -182,7 +182,7 @@ static void dummy_conversion(struct device *dev) /* Wait for data available */ do { reg_value = sys_in32(adc_base + ADC_INTSTAT); - } while ((reg_value & ADC_INTSTAT_DATA_A) == 0); + } while ((reg_value & ADC_INTSTAT_DATA_A) == 0U); /* Flush FIFO */ reg_value = sys_in32(adc_base + ADC_SET); @@ -364,7 +364,7 @@ static int adc_quark_se_ss_read_request(struct device *dev, * System clock is 32MHz, which means 1us == 32 cycles * if divider is 1. */ - interval = seq_tbl->options->interval_us * 32 / + interval = seq_tbl->options->interval_us * 32U / CONFIG_ADC_INTEL_QUARK_SE_C1000_SS_CLOCK_RATIO; if (interval < (seq_tbl->resolution + 2)) { diff --git a/drivers/adc/adc_nrfx_adc.c b/drivers/adc/adc_nrfx_adc.c index 49ca6ab4aaf..51230195d25 100644 --- a/drivers/adc/adc_nrfx_adc.c +++ b/drivers/adc/adc_nrfx_adc.c @@ -152,7 +152,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) return -EINVAL; } - if (sequence->oversampling != 0) { + if (sequence->oversampling != 0U) { LOG_ERR("Oversampling is not supported"); return -EINVAL; } diff --git a/drivers/adc/adc_nrfx_saadc.c b/drivers/adc/adc_nrfx_saadc.c index 3abb737d38b..1cf346966f7 100644 --- a/drivers/adc/adc_nrfx_saadc.c +++ b/drivers/adc/adc_nrfx_saadc.c @@ -272,7 +272,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) /* Signal an error if a selected channel has not been * configured yet. */ - if (m_data.positive_inputs[channel_id] == 0) { + if (m_data.positive_inputs[channel_id] == 0U) { LOG_ERR("Channel %u not configured", channel_id); return -EINVAL; @@ -287,7 +287,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) * possible), the burst mode have to be deactivated. */ nrf_saadc_burst_set(channel_id, - (sequence->oversampling != 0 ? + (sequence->oversampling != 0U ? NRF_SAADC_BURST_ENABLED : NRF_SAADC_BURST_DISABLED)); nrf_saadc_channel_pos_input_set( diff --git a/drivers/adc/adc_sam_afec.c b/drivers/adc/adc_sam_afec.c index 072a02b42e8..3e139024e5f 100644 --- a/drivers/adc/adc_sam_afec.c +++ b/drivers/adc/adc_sam_afec.c @@ -75,17 +75,17 @@ static int adc_sam_channel_setup(struct device *dev, u8_t channel_id = channel_cfg->channel_id; /* Clear the gain bits for the channel. */ - afec->AFEC_CGR &= ~(3 << channel_id * 2); + afec->AFEC_CGR &= ~(3 << channel_id * 2U); switch (channel_cfg->gain) { case ADC_GAIN_1: /* A value of 0 in this register is a gain of 1. */ break; case ADC_GAIN_1_2: - afec->AFEC_CGR |= (1 << (channel_id * 2)); + afec->AFEC_CGR |= (1 << (channel_id * 2U)); break; case ADC_GAIN_1_4: - afec->AFEC_CGR |= (2 << (channel_id * 2)); + afec->AFEC_CGR |= (2 << (channel_id * 2U)); break; default: LOG_ERR("Selected ADC gain is not valid"); @@ -192,18 +192,18 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) /* Signal an error if the channel selection is invalid (no channels or * a non-existing one is selected). */ - if (channels == 0 || - (channels & (~0UL << NUM_CHANNELS))) { + if (channels == 0U || + (channels & (~0UL << NUM_CHANNELS))) { LOG_ERR("Invalid selection of channels"); return -EINVAL; } - if (sequence->oversampling != 0) { + if (sequence->oversampling != 0U) { LOG_ERR("Oversampling is not supported"); return -EINVAL; } - if (sequence->resolution != 12) { + if (sequence->resolution != 12U) { /* TODO JKW: Support the Enhanced Resolution Mode 50.6.3 page * 1544. */ diff --git a/drivers/audio/intel_dmic.c b/drivers/audio/intel_dmic.c index 341d62abb36..e590e9cbef6 100644 --- a/drivers/audio/intel_dmic.c +++ b/drivers/audio/intel_dmic.c @@ -238,7 +238,7 @@ static void find_modes(struct decim_modes *modes, /* The FIFO is not requested if sample rate is set to zero. Just * return in such case with num_of_modes as zero. */ - if (fs == 0) { + if (fs == 0U) { return; } @@ -677,7 +677,7 @@ static int source_ipm_helper(struct pdm_chan_cfg *config, u32_t *source_mask, continue; } - if ((*controller_mask & BIT(pdm_ix)) == 0) { + if ((*controller_mask & BIT(pdm_ix)) == 0U) { *controller_mask |= BIT(pdm_ix); *source_mask |= pdm_ix << (ipm << 2); ipm++; @@ -696,7 +696,7 @@ static int source_ipm_helper(struct pdm_chan_cfg *config, u32_t *source_mask, * if R channel mic was requested first * set the controller to swap the channels */ - if ((pdm_lr_mask & BIT(PDM_CHAN_LEFT + (pdm_ix << 1))) == 0) { + if ((pdm_lr_mask & BIT(PDM_CHAN_LEFT + (pdm_ix << 1))) == 0U) { *swap_mask |= BIT(pdm_ix); } } @@ -749,9 +749,9 @@ static int configure_registers(struct device *dev, u32_t source_mask; /* OUTCONTROL0 and OUTCONTROL1 */ - of0 = (config->streams[0].pcm_width == 32) ? 2 : 0; + of0 = (config->streams[0].pcm_width == 32U) ? 2 : 0; if (config->channel.req_num_streams > 1) { - of1 = (config->streams[1].pcm_width == 32) ? 2 : 0; + of1 = (config->streams[1].pcm_width == 32U) ? 2 : 0; } else { of1 = 0; } @@ -792,7 +792,7 @@ static int configure_registers(struct device *dev, * for starting correct parts of the HW. */ for (i = 0; i < DMIC_HW_CONTROLLERS; i++) { - if ((controller_mask & BIT(i)) == 0) { + if ((controller_mask & BIT(i)) == 0U) { /* controller is not enabled */ continue; } @@ -802,7 +802,7 @@ static int configure_registers(struct device *dev, BIT(PDM_CHAN_RIGHT)) << (i << 1); } else { dmic_private.mic_en_mask |= - ((swap_mask & BIT(i)) == 0) ? + ((swap_mask & BIT(i)) == 0U) ? BIT(PDM_CHAN_LEFT) << (i << 1) : BIT(PDM_CHAN_RIGHT) << (i << 1); } @@ -1014,7 +1014,7 @@ static int dmic_set_config(struct device *dev, struct dmic_cfg *config) LOG_DBG("num_chan %u", config->channel.req_num_chan); LOG_DBG("req_num_streams %u", config->channel.req_num_streams); - if (config->channel.req_num_streams == 0) { + if (config->channel.req_num_streams == 0U) { LOG_ERR("req_num_streams is 0"); return -EINVAL; } @@ -1281,7 +1281,7 @@ static int dmic_trigger_device(struct device *dev, enum dmic_trigger cmd) static inline u8_t dmic_parse_clk_skew_map(u32_t skew_map, u8_t pdm) { - return (u8_t)((skew_map >> ((pdm & BIT_MASK(3)) * 4)) & BIT_MASK(4)); + return (u8_t)((skew_map >> ((pdm & BIT_MASK(3)) * 4U)) & BIT_MASK(4)); } static int dmic_initialize_device(struct device *dev) @@ -1391,7 +1391,7 @@ int dmic_configure_dma(struct pcm_stream_cfg *config, u8_t num_streams) dma_block.source_address = (u32_t)NULL; dma_block.dest_address = (u32_t)NULL; - dma_block.block_size = 0; + dma_block.block_size = 0U; dma_block.next_block = NULL; ret = dma_config(dmic_private.dma_dev, channel, &dma_cfg); diff --git a/drivers/audio/mpxxdtyy-i2s.c b/drivers/audio/mpxxdtyy-i2s.c index 17bf5dbb943..a83d4ee0f96 100644 --- a/drivers/audio/mpxxdtyy-i2s.c +++ b/drivers/audio/mpxxdtyy-i2s.c @@ -112,7 +112,7 @@ int mpxxdtyy_i2s_configure(struct device *dev, struct dmic_cfg *cfg) } factor = sw_filter_lib_init(dev, cfg); - if (factor == 0) { + if (factor == 0U) { return -EINVAL; } diff --git a/drivers/audio/mpxxdtyy.c b/drivers/audio/mpxxdtyy.c index 218f1f19043..5dfb43a99e9 100644 --- a/drivers/audio/mpxxdtyy.c +++ b/drivers/audio/mpxxdtyy.c @@ -18,7 +18,7 @@ u16_t sw_filter_lib_init(struct device *dev, struct dmic_cfg *cfg) u32_t audio_freq = cfg->streams->pcm_rate; /* calculate oversampling factor based on pdm clock */ - for (factor = 64; factor <= 128; factor += 64) { + for (factor = 64U; factor <= 128U; factor += 64U) { u32_t pdm_bit_clk = (audio_freq * factor * cfg->channel.req_num_chan); @@ -28,12 +28,12 @@ u16_t sw_filter_lib_init(struct device *dev, struct dmic_cfg *cfg) } } - if (factor != 64 && factor != 128) { + if (factor != 64U && factor != 128U) { return 0; } /* init the filter lib */ - pdm_filter->LP_HZ = audio_freq / 2; + pdm_filter->LP_HZ = audio_freq / 2U; pdm_filter->HP_HZ = 10; pdm_filter->Fs = audio_freq; pdm_filter->Out_MicChannels = 1; diff --git a/drivers/audio/tlv320dac310x.c b/drivers/audio/tlv320dac310x.c index 0cf13ba27e5..18dcba946ba 100644 --- a/drivers/audio/tlv320dac310x.c +++ b/drivers/audio/tlv320dac310x.c @@ -340,10 +340,10 @@ static int codec_configure_clocks(struct device *dev, LOG_DBG("NDAC: %u MDAC: %u OSR: %u", ndac, mdac, osr); if (i2s->options & I2S_OPT_BIT_CLK_MASTER) { - bclk_div = osr * mdac / (i2s->word_size * 2); /* stereo */ + bclk_div = osr * mdac / (i2s->word_size * 2U); /* stereo */ if ((bclk_div * i2s->word_size * 2) != (osr * mdac)) { LOG_ERR("Unable to generate BCLK %u from MCLK %u", - i2s->frame_clk_freq * i2s->word_size * 2, + i2s->frame_clk_freq * i2s->word_size * 2U, cfg->mclk_freq); return -EINVAL; } @@ -366,7 +366,7 @@ static int codec_configure_clocks(struct device *dev, } /* calculate MCLK divider to get ~1MHz */ - mclk_div = (cfg->mclk_freq + 1000000 - 1) / 1000000; + mclk_div = (cfg->mclk_freq + 1000000 - 1) / 1000000U; /* setup timer clock to be MCLK divided */ codec_write_reg(dev, TIMER_MCLK_DIV_ADDR, TIMER_MCLK_DIV_EN_EXT | TIMER_MCLK_DIV_VAL(mclk_div)); diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c index 70a92bd6d9c..c0f9f229c44 100644 --- a/drivers/bluetooth/hci/spi.c +++ b/drivers/bluetooth/hci/spi.c @@ -86,7 +86,7 @@ static inline void spi_dump_message(const u8_t *pre, u8_t *buf, for (i = 0U; i < size; i++) { c = buf[i]; printk("%x ", c); - if (c >= 31 && c <= 126) { + if (c >= 31U && c <= 126U) { printk("[%c] ", c); } else { printk("[.] "); @@ -322,9 +322,9 @@ static void bt_spi_rx_thread(void) kick_cs(); ret = bt_spi_transceive(header_master, 5, header_slave, 5); - } while ((((header_slave[STATUS_HEADER_TOREAD] == 0 || - header_slave[STATUS_HEADER_TOREAD] == 0xFF) && - !ret)) && exit_irq_high_loop()); + } while ((((header_slave[STATUS_HEADER_TOREAD] == 0U || + header_slave[STATUS_HEADER_TOREAD] == 0xFF) && + !ret)) && exit_irq_high_loop()); if (!ret) { size = header_slave[STATUS_HEADER_TOREAD]; @@ -332,7 +332,7 @@ static void bt_spi_rx_thread(void) do { ret = bt_spi_transceive(&txmsg, size, &rxmsg, size); - } while (rxmsg[0] == 0 && ret == 0); + } while (rxmsg[0] == 0U && ret == 0); } release_cs(); @@ -438,7 +438,7 @@ static int bt_spi_send(struct net_buf *buf) * sleeping or still in the initialisation stage (waking-up). */ } while ((rxmsg[STATUS_HEADER_READY] != READY_NOW || - (rxmsg[1] | rxmsg[2] | rxmsg[3] | rxmsg[4]) == 0) && !ret); + (rxmsg[1] | rxmsg[2] | rxmsg[3] | rxmsg[4]) == 0U) && !ret); k_sem_give(&sem_busy); @@ -448,7 +448,7 @@ static int bt_spi_send(struct net_buf *buf) do { ret = bt_spi_transceive(buf->data, buf->len, rxmsg, buf->len); - } while (rxmsg[0] == 0 && !ret); + } while (rxmsg[0] == 0U && !ret); } release_cs(); diff --git a/drivers/can/stm32_can.c b/drivers/can/stm32_can.c index 7992d3de867..12713b7e7b8 100644 --- a/drivers/can/stm32_can.c +++ b/drivers/can/stm32_can.c @@ -227,7 +227,7 @@ int can_stm32_runtime_configure(struct device *dev, enum can_mode mode, } prescaler = clock_rate / (BIT_SEG_LENGTH(cfg) * bitrate); - if (prescaler == 0 || prescaler > 1024) { + if (prescaler == 0U || prescaler > 1024) { LOG_ERR("HAL_CAN_Init failed: prescaler > max (%d > 1024)", prescaler); return -EINVAL; @@ -346,7 +346,7 @@ int can_stm32_send(struct device *dev, const struct zcan_frame *msg, "standard" : "extended" , msg->rtr == CAN_DATAFRAME ? "no" : "yes"); - __ASSERT(msg->dlc == 0 || msg->data != NULL, "Dataptr is null"); + __ASSERT(msg->dlc == 0U || msg->data != NULL, "Dataptr is null"); __ASSERT(msg->dlc <= CAN_MAX_DLC, "DLC > 8"); if (can->ESR & CAN_ESR_BOFF) { diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c index bdc6866b230..c0960834393 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -192,7 +192,7 @@ static void insert_char(char *pos, char c, u8_t end) /* Echo back to console */ uart_poll_out(uart_console_dev, c); - if (end == 0) { + if (end == 0U) { *pos = c; return; } @@ -217,7 +217,7 @@ static void del_char(char *pos, u8_t end) { uart_poll_out(uart_console_dev, '\b'); - if (end == 0) { + if (end == 0U) { uart_poll_out(uart_console_dev, ' '); uart_poll_out(uart_console_dev, '\b'); return; @@ -271,10 +271,10 @@ static void handle_ansi(u8_t byte, char *line) if (atomic_test_bit(&esc_state, ESC_ANSI_VAL)) { if (isdigit(byte)) { if (atomic_test_bit(&esc_state, ESC_ANSI_VAL_2)) { - ansi_val_2 *= 10; + ansi_val_2 *= 10U; ansi_val_2 += byte - '0'; } else { - ansi_val *= 10; + ansi_val *= 10U; ansi_val += byte - '0'; } return; diff --git a/drivers/counter/counter_mcux_rtc.c b/drivers/counter/counter_mcux_rtc.c index 2d7b24f1605..ab172ec8648 100644 --- a/drivers/counter/counter_mcux_rtc.c +++ b/drivers/counter/counter_mcux_rtc.c @@ -92,7 +92,7 @@ static int mcux_rtc_set_alarm(struct device *dev, u8_t chan_id, LOG_DBG("Current time is %d ticks", current); - if (chan_id != 0) { + if (chan_id != 0U) { LOG_ERR("Invalid channel id"); return -EINVAL; } @@ -123,7 +123,7 @@ static int mcux_rtc_cancel_alarm(struct device *dev, u8_t chan_id) { struct mcux_rtc_data *data = dev->driver_data; - if (chan_id != 0) { + if (chan_id != 0U) { LOG_ERR("Invalid channel id"); return -EINVAL; } diff --git a/drivers/crypto/crypto_ataes132a.c b/drivers/crypto/crypto_ataes132a.c index bafee162e2a..b314969154b 100644 --- a/drivers/crypto/crypto_ataes132a.c +++ b/drivers/crypto/crypto_ataes132a.c @@ -223,7 +223,7 @@ int ataes132a_aes_ccm_decrypt(struct device *dev, return -EINVAL; } - if (in_buf_len != 16 && in_buf_len != 32) { + if (in_buf_len != 16U && in_buf_len != 32U) { LOG_ERR("ccm mode only accepts input blocks of 16" " and 32 bytes"); return -EINVAL; @@ -279,14 +279,14 @@ int ataes132a_aes_ccm_decrypt(struct device *dev, 0x0, param_buffer, 16, param_buffer, &out_len); - if (return_code != 0) { + if (return_code != 0U) { LOG_ERR("nonce command ended with code %d", return_code); k_sem_give(&data->device_sem); return -EINVAL; } - if (param_buffer[0] != 0) { + if (param_buffer[0] != 0U) { LOG_ERR("nonce command failed with error" " code %d", param_buffer[0]); k_sem_give(&data->device_sem); @@ -354,7 +354,7 @@ int ataes132a_aes_ccm_decrypt(struct device *dev, in_buf_len + 4, param_buffer, &out_len); - if (return_code != 0) { + if (return_code != 0U) { LOG_ERR("decrypt command ended with code %d", return_code); k_sem_give(&data->device_sem); return -EINVAL; @@ -367,7 +367,7 @@ int ataes132a_aes_ccm_decrypt(struct device *dev, return -EINVAL; } - if (param_buffer[0] != 0) { + if (param_buffer[0] != 0U) { LOG_ERR("legacy command failed with error" " code %d", param_buffer[0]); k_sem_give(&data->device_sem); @@ -470,14 +470,14 @@ int ataes132a_aes_ccm_encrypt(struct device *dev, 0x0, param_buffer, 16, param_buffer, &out_len); - if (return_code != 0) { + if (return_code != 0U) { LOG_ERR("nonce command ended with code %d", return_code); k_sem_give(&data->device_sem); return -EINVAL; } - if (param_buffer[0] != 0) { + if (param_buffer[0] != 0U) { LOG_ERR("nonce command failed with error" " code %d", param_buffer[0]); k_sem_give(&data->device_sem); @@ -526,7 +526,7 @@ int ataes132a_aes_ccm_encrypt(struct device *dev, buf_len + 2, param_buffer, &out_len); - if (return_code != 0) { + if (return_code != 0U) { LOG_ERR("encrypt command ended with code %d", return_code); k_sem_give(&data->device_sem); return -EINVAL; @@ -539,7 +539,7 @@ int ataes132a_aes_ccm_encrypt(struct device *dev, return -EINVAL; } - if (param_buffer[0] != 0) { + if (param_buffer[0] != 0U) { LOG_ERR("encrypt command failed with error" " code %d", param_buffer[0]); k_sem_give(&data->device_sem); @@ -549,7 +549,7 @@ int ataes132a_aes_ccm_encrypt(struct device *dev, if (aead_op->tag) { memcpy(aead_op->tag, param_buffer + 1, 16); } - memcpy(aead_op->pkt->out_buf, param_buffer + 17, out_len - 17); + memcpy(aead_op->pkt->out_buf, param_buffer + 17, out_len - 17U); if (mac_mode) { if (mac_mode->include_counter) { @@ -560,7 +560,7 @@ int ataes132a_aes_ccm_encrypt(struct device *dev, ataes132a_send_command(dev, ATAES_INFO_OP, 0x0, param_buffer, 4, param_buffer, &out_len); - if (param_buffer[0] != 0) { + if (param_buffer[0] != 0U) { LOG_ERR("info command failed with error" " code %d", param_buffer[0]); k_sem_give(&data->device_sem); @@ -639,19 +639,19 @@ int ataes132a_aes_ecb_block(struct device *dev, param_buffer, buf_len + 3, param_buffer, &out_len); - if (return_code != 0) { + if (return_code != 0U) { LOG_ERR("legacy command ended with code %d", return_code); k_sem_give(&data->device_sem); return -EINVAL; } - if (out_len != 17) { + if (out_len != 17U) { LOG_ERR("legacy command response has invalid" " size %d", out_len); k_sem_give(&data->device_sem); return -EINVAL; } - if (param_buffer[0] != 0) { + if (param_buffer[0] != 0U) { LOG_ERR("legacy command failed with error" " code %d", param_buffer[0]); k_sem_give(&data->device_sem); @@ -703,7 +703,7 @@ static int do_ccm_encrypt_mac(struct cipher_ctx *ctx, aead_op->pkt->out_len = 32; } - if (aead_op->ad != NULL || aead_op->ad_len != 0) { + if (aead_op->ad != NULL || aead_op->ad_len != 0U) { LOG_ERR("Associated data is not supported."); return -EINVAL; } @@ -748,7 +748,7 @@ static int do_ccm_decrypt_auth(struct cipher_ctx *ctx, aead_op->pkt->ctx = ctx; - if (aead_op->ad != NULL || aead_op->ad_len != 0) { + if (aead_op->ad != NULL || aead_op->ad_len != 0U) { LOG_ERR("Associated data is not supported."); return -EINVAL; } @@ -806,12 +806,12 @@ static int ataes132a_session_setup(struct device *dev, struct cipher_ctx *ctx, return -EINVAL; } if (mode == CRYPTO_CIPHER_MODE_CCM && - ctx->mode_params.ccm_info.tag_len != 16) { + ctx->mode_params.ccm_info.tag_len != 16U) { LOG_ERR("ATAES132A support 16 byte tag only."); return -EINVAL; } if (mode == CRYPTO_CIPHER_MODE_CCM && - ctx->mode_params.ccm_info.nonce_len != 12) { + ctx->mode_params.ccm_info.nonce_len != 12U) { LOG_ERR("ATAES132A support 12 byte nonce only."); return -EINVAL; } diff --git a/drivers/crypto/crypto_ataes132a_priv.h b/drivers/crypto/crypto_ataes132a_priv.h index a5cf931fd34..bc01116e17b 100644 --- a/drivers/crypto/crypto_ataes132a_priv.h +++ b/drivers/crypto/crypto_ataes132a_priv.h @@ -147,7 +147,7 @@ static inline int burst_write_i2c(struct device *dev, u16_t dev_addr, addr_buffer[1] = start_addr & 0xFF; addr_buffer[0] = start_addr >> 8; msg[0].buf = addr_buffer; - msg[0].len = 2; + msg[0].len = 2U; msg[0].flags = I2C_MSG_WRITE; msg[1].buf = buf; @@ -169,7 +169,7 @@ static inline int burst_read_i2c(struct device *dev, u16_t dev_addr, addr_buffer[1] = start_addr & 0xFF; addr_buffer[0] = start_addr >> 8; msg[0].buf = addr_buffer; - msg[0].len = 2; + msg[0].len = 2U; msg[0].flags = I2C_MSG_WRITE; msg[1].buf = buf; diff --git a/drivers/crypto/crypto_mtls_shim.c b/drivers/crypto/crypto_mtls_shim.c index dbd8dd3037f..fe85fdfe502 100644 --- a/drivers/crypto/crypto_mtls_shim.c +++ b/drivers/crypto/crypto_mtls_shim.c @@ -138,7 +138,7 @@ static int mtls_session_setup(struct device *dev, struct cipher_ctx *ctx, return -EINVAL; } - if (ctx->keylen != 16) { + if (ctx->keylen != 16U) { LOG_ERR("%u key size is not supported", ctx->keylen); return -EINVAL; } @@ -154,7 +154,7 @@ static int mtls_session_setup(struct device *dev, struct cipher_ctx *ctx, mbedtls_ccm_init(mtls_ctx); ret = mbedtls_ccm_setkey(mtls_ctx, MBEDTLS_CIPHER_ID_AES, - ctx->key.bit_stream, ctx->keylen * 8); + ctx->key.bit_stream, ctx->keylen * 8U); if (ret) { LOG_ERR("Could not setup the key (%d)", ret); mtls_sessions[ctx_idx].in_use = false; diff --git a/drivers/crypto/crypto_tc_shim.c b/drivers/crypto/crypto_tc_shim.c index 743c196aae3..a0784e0526f 100644 --- a/drivers/crypto/crypto_tc_shim.c +++ b/drivers/crypto/crypto_tc_shim.c @@ -223,7 +223,7 @@ static int tc_session_setup(struct device *dev, struct cipher_ctx *ctx, ctx->ops.cbc_crypt_hndlr = do_cbc_encrypt; break; case CRYPTO_CIPHER_MODE_CTR: - if (ctx->mode_params.ctr_info.ctr_len != 32) { + if (ctx->mode_params.ctr_info.ctr_len != 32U) { LOG_ERR("Tinycrypt supports only 32 bit " "counter"); return -EINVAL; @@ -244,7 +244,7 @@ static int tc_session_setup(struct device *dev, struct cipher_ctx *ctx, break; case CRYPTO_CIPHER_MODE_CTR: /* Maybe validate CTR length */ - if (ctx->mode_params.ctr_info.ctr_len != 32) { + if (ctx->mode_params.ctr_info.ctr_len != 32U) { LOG_ERR("Tinycrypt supports only 32 bit " "counter"); return -EINVAL; diff --git a/drivers/display/display_ili9340.c b/drivers/display/display_ili9340.c index 6d9e5ee70b0..468c44b084e 100644 --- a/drivers/display/display_ili9340.c +++ b/drivers/display/display_ili9340.c @@ -55,7 +55,7 @@ static int ili9340_init(struct device *dev) data->cs_ctrl.gpio_dev = device_get_binding(DT_ILITEK_ILI9340_0_CS_GPIO_CONTROLLER); data->cs_ctrl.gpio_pin = DT_ILITEK_ILI9340_0_CS_GPIO_PIN; - data->cs_ctrl.delay = 0; + data->cs_ctrl.delay = 0U; data->spi_config.cs = &(data->cs_ctrl); #else data->spi_config.cs = NULL; @@ -229,8 +229,8 @@ static void ili9340_get_capabilities(const struct device *dev, struct display_capabilities *capabilities) { memset(capabilities, 0, sizeof(struct display_capabilities)); - capabilities->x_resolution = 320; - capabilities->y_resolution = 240; + capabilities->x_resolution = 320U; + capabilities->y_resolution = 240U; capabilities->supported_pixel_formats = PIXEL_FORMAT_RGB_888; capabilities->current_pixel_format = PIXEL_FORMAT_RGB_888; capabilities->current_orientation = DISPLAY_ORIENTATION_NORMAL; diff --git a/drivers/display/display_mcux_elcdif.c b/drivers/display/display_mcux_elcdif.c index 573a545f7c7..c1b56f73ec2 100644 --- a/drivers/display/display_mcux_elcdif.c +++ b/drivers/display/display_mcux_elcdif.c @@ -183,10 +183,10 @@ static int mcux_elcdif_init(struct device *dev) elcdif_rgb_mode_config_t rgb_mode = config->rgb_mode; - data->pixel_bytes = config->bits_per_pixel / 8; + data->pixel_bytes = config->bits_per_pixel / 8U; data->fb_bytes = data->pixel_bytes * rgb_mode.panelWidth * rgb_mode.panelHeight; - data->write_idx = 1; + data->write_idx = 1U; for (i = 0; i < ARRAY_SIZE(data->fb); i++) { if (k_mem_pool_alloc(&mcux_elcdif_pool, &data->fb[i], diff --git a/drivers/display/display_sdl.c b/drivers/display/display_sdl.c index d1e1a897e4c..cc4dbe06715 100644 --- a/drivers/display/display_sdl.c +++ b/drivers/display/display_sdl.c @@ -89,8 +89,8 @@ static void sdl_display_write_rgb888(u8_t *disp_buf, __ASSERT((3 * desc->pitch * desc->height) <= desc->buf_size, "Input buffer to small"); - for (h_idx = 0; h_idx < desc->height; ++h_idx) { - for (w_idx = 0; w_idx < desc->width; ++w_idx) { + for (h_idx = 0U; h_idx < desc->height; ++h_idx) { + for (w_idx = 0U; w_idx < desc->width; ++w_idx) { byte_ptr = (const u8_t *)buf + 3 * ((h_idx * desc->pitch) + w_idx); pixel = *byte_ptr << 16; @@ -116,22 +116,22 @@ static void sdl_display_write_mono(u8_t *disp_buf, __ASSERT((desc->pitch * desc->height) <= (8 * desc->buf_size), "Input buffer to small"); - __ASSERT((desc->height % 8) == 0, + __ASSERT((desc->height % 8) == 0U, "Input buffer height not aligned per 8 pixels"); if (one_is_black) { - one_color = 0; + one_color = 0U; } else { one_color = 0x00FFFFFF; } - for (tile_idx = 0; tile_idx < desc->height/8; ++tile_idx) { - for (w_idx = 0; w_idx < desc->width; ++w_idx) { + for (tile_idx = 0U; tile_idx < desc->height/8U; ++tile_idx) { + for (w_idx = 0U; w_idx < desc->width; ++w_idx) { byte_ptr = (const u8_t *)buf + ((tile_idx * desc->pitch) + w_idx); disp_buf_start = disp_buf; - for (h_idx = 0; h_idx < 8; ++h_idx) { - if ((*byte_ptr & BIT(7-h_idx)) != 0) { + for (h_idx = 0U; h_idx < 8; ++h_idx) { + if ((*byte_ptr & BIT(7-h_idx)) != 0U) { pixel = one_color; } else { pixel = (~one_color) & 0x00FFFFFF; diff --git a/drivers/display/grove_lcd_rgb.c b/drivers/display/grove_lcd_rgb.c index 92a27d3e6f9..caac46e4ef5 100644 --- a/drivers/display/grove_lcd_rgb.c +++ b/drivers/display/grove_lcd_rgb.c @@ -125,7 +125,7 @@ void glcd_cursor_pos_set(struct device *port, u8_t col, u8_t row) unsigned char data[2]; - if (row == 0) { + if (row == 0U) { col |= 0x80; } else { col |= 0xC0; diff --git a/drivers/display/mb_display.c b/drivers/display/mb_display.c index 7a18c333565..e925e14cbec 100644 --- a/drivers/display/mb_display.c +++ b/drivers/display/mb_display.c @@ -308,7 +308,7 @@ static void show_row(struct k_timer *timer) update_pins(disp, disp->row[disp->cur]); disp->cur = (disp->cur + 1) % DISPLAY_ROWS; - if (disp->cur == 0 && disp->expiry != K_FOREVER && + if (disp->cur == 0U && disp->expiry != K_FOREVER && k_uptime_get() > disp->expiry) { if (disp->scroll) { update_scroll(disp); diff --git a/drivers/display/ssd1306.c b/drivers/display/ssd1306.c index 0c88b26183a..6ff1af5c570 100644 --- a/drivers/display/ssd1306.c +++ b/drivers/display/ssd1306.c @@ -228,7 +228,7 @@ int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y, return -1; } - if (buf == NULL || desc->buf_size == 0) { + if (buf == NULL || desc->buf_size == 0U) { LOG_ERR("Display buffer is not available"); return -1; } @@ -238,7 +238,7 @@ int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y, return -1; } - if (x != 0 && y != 0) { + if (x != 0U && y != 0U) { LOG_ERR("Unsupported origin"); return -1; } diff --git a/drivers/display/ssd1673.c b/drivers/display/ssd1673.c index 7125212d6b4..8c0585fb258 100644 --- a/drivers/display/ssd1673.c +++ b/drivers/display/ssd1673.c @@ -277,7 +277,7 @@ static int ssd1673_write(const struct device *dev, const u16_t x, return -EINVAL; } - if (buf == NULL || desc->buf_size == 0) { + if (buf == NULL || desc->buf_size == 0U) { LOG_ERR("Display buffer is not available"); return -EINVAL; } @@ -297,13 +297,13 @@ static int ssd1673_write(const struct device *dev, const u16_t x, return -EINVAL; } - if ((desc->height % EPD_PANEL_NUMOF_ROWS_PER_PAGE) != 0) { + if ((desc->height % EPD_PANEL_NUMOF_ROWS_PER_PAGE) != 0U) { LOG_ERR("Buffer height not multiple of %d", EPD_PANEL_NUMOF_ROWS_PER_PAGE); return -EINVAL; } - if ((y % EPD_PANEL_NUMOF_ROWS_PER_PAGE) != 0) { + if ((y % EPD_PANEL_NUMOF_ROWS_PER_PAGE) != 0U) { LOG_ERR("Y coordinate not multiple of %d", EPD_PANEL_NUMOF_ROWS_PER_PAGE); return -EINVAL; @@ -461,7 +461,7 @@ static int ssd1673_clear_and_write_buffer(struct device *dev) memset(clear_page, 0xff, sizeof(clear_page)); sbuf.buf = clear_page; sbuf.len = sizeof(clear_page); - for (page = 0; page <= (SSD1673_PANEL_LAST_PAGE + 1); ++page) { + for (page = 0U; page <= (SSD1673_PANEL_LAST_PAGE + 1); ++page) { err = spi_write(driver->spi_dev, &driver->spi_config, &buf_set); if (err < 0) { return err; @@ -629,7 +629,7 @@ static int ssd1673_init(struct device *dev) } driver->cs_ctrl.gpio_pin = DT_SOLOMON_SSD1673FB_0_CS_GPIO_PIN; - driver->cs_ctrl.delay = 0; + driver->cs_ctrl.delay = 0U; driver->spi_config.cs = &driver->cs_ctrl; #endif diff --git a/drivers/dma/dma_nios2_msgdma.c b/drivers/dma/dma_nios2_msgdma.c index 15f44ca8b3e..0eb7ad558a4 100644 --- a/drivers/dma/dma_nios2_msgdma.c +++ b/drivers/dma/dma_nios2_msgdma.c @@ -74,7 +74,7 @@ static int nios2_msgdma_config(struct device *dev, u32_t channel, u32_t control; /* Nios-II MSGDMA supports only one channel per DMA core */ - if (channel != 0) { + if (channel != 0U) { LOG_ERR("invalid channel number"); return -EINVAL; } @@ -85,7 +85,7 @@ static int nios2_msgdma_config(struct device *dev, u32_t channel, return -EINVAL; } #else - if (cfg->block_count != 1) { + if (cfg->block_count != 1U) { LOG_ERR("invalid block count!!"); return -EINVAL; } @@ -156,7 +156,7 @@ static int nios2_msgdma_transfer_start(struct device *dev, u32_t channel) int status; /* Nios-II mSGDMA supports only one channel per DMA core */ - if (channel != 0) { + if (channel != 0U) { LOG_ERR("Invalid channel number"); return -EINVAL; } diff --git a/drivers/dma/dma_qmsi.c b/drivers/dma/dma_qmsi.c index c52b28ac8b9..05ec6d4073a 100644 --- a/drivers/dma/dma_qmsi.c +++ b/drivers/dma/dma_qmsi.c @@ -136,7 +136,7 @@ static int dma_qmsi_chan_config(struct device *dev, u32_t channel, u32_t temp = 0U; int ret = 0; - if (config->block_count != 1) { + if (config->block_count != 1U) { return -ENOTSUP; } diff --git a/drivers/dma/dma_sam_xdmac.c b/drivers/dma/dma_sam_xdmac.c index d8fa0174093..68d2f12bfca 100644 --- a/drivers/dma/dma_sam_xdmac.c +++ b/drivers/dma/dma_sam_xdmac.c @@ -191,13 +191,13 @@ static int sam_xdmac_config(struct device *dev, u32_t channel, __ASSERT_NO_MSG(cfg->source_data_size == cfg->dest_data_size); __ASSERT_NO_MSG(cfg->source_burst_length == cfg->dest_burst_length); - if (cfg->source_data_size != 1 && cfg->source_data_size != 2 && - cfg->source_data_size != 4) { + if (cfg->source_data_size != 1U && cfg->source_data_size != 2U && + cfg->source_data_size != 4U) { LOG_ERR("Invalid 'source_data_size' value"); return -EINVAL; } - if (cfg->block_count != 1) { + if (cfg->block_count != 1U) { LOG_ERR("Only single block transfer is currently supported." " Please submit a patch."); return -EINVAL; @@ -212,7 +212,7 @@ static int sam_xdmac_config(struct device *dev, u32_t channel, case MEMORY_TO_MEMORY: channel_cfg.cfg = XDMAC_CC_TYPE_MEM_TRAN - | XDMAC_CC_MBSIZE(burst_size == 0 ? 0 : burst_size - 1) + | XDMAC_CC_MBSIZE(burst_size == 0U ? 0 : burst_size - 1) | XDMAC_CC_SAM_INCREMENTED_AM | XDMAC_CC_DAM_INCREMENTED_AM; break; diff --git a/drivers/dma/dma_stm32f4x.c b/drivers/dma/dma_stm32f4x.c index 1e151ed3611..2561a1d966b 100644 --- a/drivers/dma/dma_stm32f4x.c +++ b/drivers/dma/dma_stm32f4x.c @@ -210,13 +210,13 @@ static u32_t dma_stm32_irq_status(struct dma_stm32_device *ddata, irqs = dma_stm32_read(ddata, DMA_STM32_LISR); } - return (irqs >> (((id & 2) << 3) | ((id & 1) * 6))); + return (irqs >> (((id & 2) << 3) | ((id & 1) * 6U))); } static void dma_stm32_irq_clear(struct dma_stm32_device *ddata, u32_t id, u32_t irqs) { - irqs = irqs << (((id & 2) << 3) | ((id & 1) * 6)); + irqs = irqs << (((id & 2) << 3) | ((id & 1) * 6U)); if (id & 4) { dma_stm32_write(ddata, DMA_STM32_HIFCR, irqs); diff --git a/drivers/entropy/entropy_nrf5.c b/drivers/entropy/entropy_nrf5.c index ded1452318e..fe1e87f2a7e 100644 --- a/drivers/entropy/entropy_nrf5.c +++ b/drivers/entropy/entropy_nrf5.c @@ -235,7 +235,7 @@ static int entropy_nrf5_get_entropy(struct device *device, u8_t *buf, u16_t len) buf, len); k_sem_give(&entropy_nrf5_data.sem_lock); - if (bytes == 0) { + if (bytes == 0U) { /* Pool is empty: Sleep until next interrupt. */ k_sem_take(&entropy_nrf5_data.sem_sync, K_FOREVER); continue; @@ -256,7 +256,7 @@ static int entropy_nrf5_get_entropy_isr(struct device *dev, u8_t *buf, u16_t len /* Check if this API is called on correct driver instance. */ __ASSERT_NO_MSG(&entropy_nrf5_data == DEV_DATA(dev)); - if (likely((flags & ENTROPY_BUSYWAIT) == 0)) { + if (likely((flags & ENTROPY_BUSYWAIT) == 0U)) { return rng_pool_get((struct rng_pool *)(entropy_nrf5_data.isr), buf, len); } diff --git a/drivers/ethernet/eth_dw.c b/drivers/ethernet/eth_dw.c index 4067bff60ef..02db4ecc856 100644 --- a/drivers/ethernet/eth_dw.c +++ b/drivers/ethernet/eth_dw.c @@ -196,7 +196,7 @@ static void eth_dw_isr(struct device *dev) * by the shared IRQ driver. So check here if the interrupt * is coming from the GPIO controller (or somewhere else). */ - if ((int_status & STATUS_RX_INT) == 0) { + if ((int_status & STATUS_RX_INT) == 0U) { return; } #endif diff --git a/drivers/ethernet/eth_sam_gmac.c b/drivers/ethernet/eth_sam_gmac.c index 6b02d223788..83d327dbd71 100644 --- a/drivers/ethernet/eth_sam_gmac.c +++ b/drivers/ethernet/eth_sam_gmac.c @@ -250,11 +250,11 @@ static int rx_descriptors_init(Gmac *gmac, struct gmac_queue *queue) "Incorrect length of RX data buffer"); /* Give ownership to GMAC and remove the wrap bit */ rx_desc_list->buf[i].w0 = (u32_t)rx_buf_addr & GMAC_RXW0_ADDR; - rx_desc_list->buf[i].w1 = 0; + rx_desc_list->buf[i].w1 = 0U; } /* Set the wrap bit on the last descriptor */ - rx_desc_list->buf[rx_desc_list->len - 1].w0 |= GMAC_RXW0_WRAP; + rx_desc_list->buf[rx_desc_list->len - 1U].w0 |= GMAC_RXW0_WRAP; return 0; } @@ -270,12 +270,12 @@ static void tx_descriptors_init(Gmac *gmac, struct gmac_queue *queue) tx_desc_list->tail = 0U; for (int i = 0; i < tx_desc_list->len; i++) { - tx_desc_list->buf[i].w0 = 0; + tx_desc_list->buf[i].w0 = 0U; tx_desc_list->buf[i].w1 = GMAC_TXW1_USED; } /* Set the wrap bit on the last descriptor */ - tx_desc_list->buf[tx_desc_list->len - 1].w1 |= GMAC_TXW1_WRAP; + tx_desc_list->buf[tx_desc_list->len - 1U].w1 |= GMAC_TXW1_WRAP; #if GMAC_MULTIPLE_TX_PACKETS == 1 /* Reset TX frame list */ @@ -608,7 +608,7 @@ static void rx_error_handler(Gmac *gmac, struct gmac_queue *queue) queue->rx_desc_list.tail = 0U; for (int i = 0; i < queue->rx_desc_list.len; i++) { - queue->rx_desc_list.buf[i].w1 = 0; + queue->rx_desc_list.buf[i].w1 = 0U; queue->rx_desc_list.buf[i].w0 &= ~GMAC_RXW0_OWNERSHIP; } @@ -633,17 +633,17 @@ static int get_mck_clock_divisor(u32_t mck) { u32_t mck_divisor; - if (mck <= 20000000) { + if (mck <= 20000000U) { mck_divisor = GMAC_NCFGR_CLK_MCK_8; - } else if (mck <= 40000000) { + } else if (mck <= 40000000U) { mck_divisor = GMAC_NCFGR_CLK_MCK_16; - } else if (mck <= 80000000) { + } else if (mck <= 80000000U) { mck_divisor = GMAC_NCFGR_CLK_MCK_32; - } else if (mck <= 120000000) { + } else if (mck <= 120000000U) { mck_divisor = GMAC_NCFGR_CLK_MCK_48; - } else if (mck <= 160000000) { + } else if (mck <= 160000000U) { mck_divisor = GMAC_NCFGR_CLK_MCK_64; - } else if (mck <= 240000000) { + } else if (mck <= 240000000U) { mck_divisor = GMAC_NCFGR_CLK_MCK_96; } else { LOG_ERR("No valid MDC clock"); @@ -754,7 +754,7 @@ static int eth_sam_gmac_get_qav_idle_slope(Gmac *gmac, int queue_id, } /* Convert to bps as expected by upper layer */ - *idle_slope *= 8; + *idle_slope *= 8U; return 0; } @@ -772,7 +772,7 @@ static int eth_sam_gmac_get_qav_delta_bandwidth(Gmac *gmac, int queue_id, } /* Calculate in Bps */ - idle_slope /= 8; + idle_slope /= 8U; /* Get bandwidth and convert to bps */ bandwidth = eth_sam_gmac_get_bandwidth(gmac); @@ -781,7 +781,7 @@ static int eth_sam_gmac_get_qav_delta_bandwidth(Gmac *gmac, int queue_id, * divide bandwidth - these numbers are so large that it should not * influence the outcome and saves us from employing larger data types. */ - *delta_bandwidth = idle_slope / (bandwidth / 100); + *delta_bandwidth = idle_slope / (bandwidth / 100U); return 0; } @@ -799,7 +799,7 @@ static int eth_sam_gmac_setup_qav_delta_bandwidth(Gmac *gmac, int queue_id, bandwidth = eth_sam_gmac_get_bandwidth(gmac); - idle_slope = (bandwidth * queue_share) / 100; + idle_slope = (bandwidth * queue_share) / 100U; return eth_sam_gmac_setup_qav_idle_slope(gmac, queue_id, idle_slope); } @@ -1052,16 +1052,16 @@ static int priority_queue_init_as_idle(Gmac *gmac, struct gmac_queue *queue) "RX descriptors have to be word aligned"); __ASSERT(!((u32_t)tx_desc_list->buf & ~GMAC_TBQB_ADDR_Msk), "TX descriptors have to be word aligned"); - __ASSERT((rx_desc_list->len == 1) && (tx_desc_list->len == 1), + __ASSERT((rx_desc_list->len == 1U) && (tx_desc_list->len == 1U), "Priority queues are currently not supported, descriptor " "list has to have a single entry"); /* Setup RX descriptor lists */ /* Take ownership from GMAC and set the wrap bit */ rx_desc_list->buf[0].w0 = GMAC_RXW0_WRAP; - rx_desc_list->buf[0].w1 = 0; + rx_desc_list->buf[0].w1 = 0U; /* Setup TX descriptor lists */ - tx_desc_list->buf[0].w0 = 0; + tx_desc_list->buf[0].w0 = 0U; /* Take ownership from GMAC and set the wrap bit */ tx_desc_list->buf[0].w1 = GMAC_TXW1_USED | GMAC_TXW1_WRAP; @@ -1179,13 +1179,13 @@ static struct net_pkt *frame_get(struct gmac_queue *queue) } /* Update buffer descriptor status word */ - rx_desc->w1 = 0; + rx_desc->w1 = 0U; /* Guarantee that status word is written before the address * word to avoid race condition. */ __DMB(); /* data memory barrier */ /* Update buffer descriptor address word */ - wrap = (tail == rx_desc_list->len-1 ? GMAC_RXW0_WRAP : 0); + wrap = (tail == rx_desc_list->len-1U ? GMAC_RXW0_WRAP : 0); rx_desc->w0 = ((u32_t)frag->data & GMAC_RXW0_ADDR) | wrap; MODULO_INC(tail, rx_desc_list->len); @@ -1379,7 +1379,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) */ tx_desc->w1 = (frag_len & GMAC_TXW1_LEN) | (!frag->frags ? GMAC_TXW1_LASTBUFFER : 0) - | (tx_desc_list->head == tx_desc_list->len - 1 + | (tx_desc_list->head == tx_desc_list->len - 1U ? GMAC_TXW1_WRAP : 0) | (tx_desc == tx_first_desc ? GMAC_TXW1_USED : 0); @@ -1814,7 +1814,7 @@ static int eth_sam_gmac_set_qav_param(struct device *dev, idle_slope = config->qav_param.idle_slope; /* The standard uses bps, SAM GMAC uses Bps - convert now */ - idle_slope /= 8; + idle_slope /= 8U; return eth_sam_gmac_setup_qav_idle_slope(gmac, queue_id, idle_slope); diff --git a/drivers/ethernet/eth_smsc911x.c b/drivers/ethernet/eth_smsc911x.c index 859cae9bc3d..be057268aee 100644 --- a/drivers/ethernet/eth_smsc911x.c +++ b/drivers/ethernet/eth_smsc911x.c @@ -81,8 +81,8 @@ static int smsc_mac_regwrite(u8_t reg, u32_t val) int smsc_phy_regread(u8_t regoffset, u32_t *data) { - u32_t val = 0; - u32_t phycmd = 0; + u32_t val = 0U; + u32_t phycmd = 0U; unsigned int time_out = REG_WRITE_TIMEOUT; if (smsc_mac_regread(SMSC9220_MAC_MII_ACC, &val) < 0) { @@ -90,11 +90,11 @@ int smsc_phy_regread(u8_t regoffset, u32_t *data) } if (val & MAC_MII_ACC_MIIBZY) { - *data = 0; + *data = 0U; return -EBUSY; } - phycmd = 0; + phycmd = 0U; phycmd |= PHY_ADDR << 11; phycmd |= (regoffset & 0x1F) << 6; phycmd |= MAC_MII_ACC_READ; @@ -104,16 +104,16 @@ int smsc_phy_regread(u8_t regoffset, u32_t *data) return -1; } - val = 0; + val = 0U; do { k_sleep(1); time_out--; if (smsc_mac_regread(SMSC9220_MAC_MII_ACC, &val)) { return -1; } - } while (time_out != 0 && (val & MAC_MII_ACC_MIIBZY)); + } while (time_out != 0U && (val & MAC_MII_ACC_MIIBZY)); - if (time_out == 0) { + if (time_out == 0U) { return -ETIMEDOUT; } @@ -126,8 +126,8 @@ int smsc_phy_regread(u8_t regoffset, u32_t *data) int smsc_phy_regwrite(u8_t regoffset, u32_t data) { - u32_t val = 0; - u32_t phycmd = 0; + u32_t val = 0U; + u32_t phycmd = 0U; unsigned int time_out = REG_WRITE_TIMEOUT; if (smsc_mac_regread(SMSC9220_MAC_MII_ACC, &val) < 0) { @@ -157,9 +157,9 @@ int smsc_phy_regwrite(u8_t regoffset, u32_t data) if (smsc_mac_regread(SMSC9220_MAC_MII_ACC, &phycmd)) { return -1; } - } while (time_out != 0 && (phycmd & MAC_MII_ACC_MIIBZY)); + } while (time_out != 0U && (phycmd & MAC_MII_ACC_MIIBZY)); - if (time_out == 0) { + if (time_out == 0U) { return -ETIMEDOUT; } @@ -224,9 +224,9 @@ static int smsc_soft_reset(void) do { k_sleep(1); time_out--; - } while (time_out != 0 && (SMSC9220->HW_CFG & HW_CFG_SRST)); + } while (time_out != 0U && (SMSC9220->HW_CFG & HW_CFG_SRST)); - if (time_out == 0) { + if (time_out == 0U) { return -1; } @@ -236,7 +236,7 @@ static int smsc_soft_reset(void) void smsc_set_txfifo(unsigned int val) { /* 2kb minimum, 14kb maximum */ - if (val >= 2 && val <= 14) { + if (val >= 2U && val <= 14U) { SMSC9220->HW_CFG = val << 16; } } @@ -289,7 +289,7 @@ int smsc_reset_phy(void) */ void smsc_advertise_caps(void) { - u32_t aneg_adv = 0; + u32_t aneg_adv = 0U; smsc_phy_regread(SMSC9220_PHY_ANEG_ADV, &aneg_adv); aneg_adv |= 0xDE0; @@ -300,8 +300,8 @@ void smsc_advertise_caps(void) void smsc_establish_link(void) { - u32_t bcr = 0; - u32_t hw_cfg = 0; + u32_t bcr = 0U; + u32_t hw_cfg = 0U; smsc_phy_regread(SMSC9220_PHY_BCONTROL, &bcr); bcr |= (1 << 12) | (1 << 9); @@ -321,7 +321,7 @@ inline void smsc_enable_xmit(void) void smsc_enable_mac_xmit(void) { - u32_t mac_cr = 0; + u32_t mac_cr = 0U; smsc_mac_regread(SMSC9220_MAC_CR, &mac_cr); @@ -333,7 +333,7 @@ void smsc_enable_mac_xmit(void) void smsc_enable_mac_recv(void) { - u32_t mac_cr = 0; + u32_t mac_cr = 0U; smsc_mac_regread(SMSC9220_MAC_CR, &mac_cr); mac_cr |= (1 << 2); /* Recv enable */ @@ -342,7 +342,7 @@ void smsc_enable_mac_recv(void) int smsc_init(void) { - unsigned int phyreset = 0; + unsigned int phyreset = 0U; if (smsc_check_id() < 0) { return -1; @@ -455,13 +455,13 @@ static int smsc_write_tx_fifo(const u8_t *buf, u32_t len, bool is_last) len = (len + 3) & ~3; } - if ((len & 3) != 0 || len == 0) { + if ((len & 3) != 0U || len == 0U) { LOG_ERR("Chunk size not aligned: %u", len); return -1; } buf32 = (u32_t *)buf; - len /= 4; + len /= 4U; do { SMSC9220->TX_DATA_PORT = *buf32++; } while (--len); @@ -536,9 +536,9 @@ static int smsc_read_rx_fifo(struct net_pkt *pkt, u32_t len) { u32_t buf32; - __ASSERT_NO_MSG((len & 3) == 0 && len >= 4); + __ASSERT_NO_MSG((len & 3) == 0U && len >= 4U); - len /= 4; + len /= 4U; do { buf32 = SMSC9220->RX_DATA_PORT; @@ -560,7 +560,7 @@ static struct net_pkt *smsc_recv_pkt(struct device *dev, u32_t pkt_size) /* Round up to next DWORD size */ rem_size = (pkt_size + 3) & ~3; /* Don't account for FCS when filling net pkt */ - rem_size -= 4; + rem_size -= 4U; pkt = net_pkt_rx_alloc_with_buffer(context->iface, rem_size, AF_UNSPEC, 0, K_NO_WAIT); @@ -616,7 +616,7 @@ static void eth_smsc911x_isr(struct device *dev) * pending for as long as there're packets in FIFO. And when * there's none, finally acknowledge it. */ - if (pkt_pending == 0) { + if (pkt_pending == 0U) { goto done; } diff --git a/drivers/ethernet/eth_stellaris.c b/drivers/ethernet/eth_stellaris.c index fc6be01a523..de6154a094e 100644 --- a/drivers/ethernet/eth_stellaris.c +++ b/drivers/ethernet/eth_stellaris.c @@ -41,7 +41,7 @@ static void eth_stellaris_flush(struct device *dev) if (dev_data->tx_pos != 0) { sys_write32(dev_data->tx_word, REG_MACDATA); dev_data->tx_pos = 0; - dev_data->tx_word = 0; + dev_data->tx_word = 0U; } } @@ -54,7 +54,7 @@ static void eth_stellaris_send_byte(struct device *dev, u8_t byte) if (dev_data->tx_pos == 4) { sys_write32(dev_data->tx_word, REG_MACDATA); dev_data->tx_pos = 0; - dev_data->tx_word = 0; + dev_data->tx_word = 0U; } } @@ -74,7 +74,7 @@ static int eth_stellaris_send(struct device *dev, struct net_pkt *pkt) /* Send the payload */ for (frag = pkt->frags; frag; frag = frag->frags) { - for (i = 0; i < frag->len; ++i) { + for (i = 0U; i < frag->len; ++i) { eth_stellaris_send_byte(dev, frag->data[i]); } } @@ -150,7 +150,7 @@ static struct net_pkt *eth_stellaris_rx_pkt(struct device *dev, * The remaining 2 bytes, in the first word is appended to the * ethernet frame. */ - count = 2; + count = 2U; data = (u8_t *)®_val + 2; if (net_pkt_write(pkt, data, count)) { goto error; @@ -162,7 +162,7 @@ static struct net_pkt *eth_stellaris_rx_pkt(struct device *dev, /* Read the rest of words, minus the partial word and FCS byte. */ for (; bytes_left > 7; bytes_left -= 4) { reg_val = sys_read32(REG_MACDATA); - count = 4; + count = 4U; data = (u8_t *)®_val; if (net_pkt_write(pkt, data, count)) { goto error; diff --git a/drivers/ethernet/phy_sam_gmac.c b/drivers/ethernet/phy_sam_gmac.c index 111008a671b..3c36478c6bd 100644 --- a/drivers/ethernet/phy_sam_gmac.c +++ b/drivers/ethernet/phy_sam_gmac.c @@ -42,7 +42,7 @@ static int mdio_bus_wait(Gmac *gmac) u32_t retries = 100U; /* will wait up to 1 s */ while (!(gmac->GMAC_NSR & GMAC_NSR_IDLE)) { - if (retries-- == 0) { + if (retries-- == 0U) { LOG_ERR("timeout"); return -ETIMEDOUT; } @@ -123,7 +123,7 @@ static int phy_soft_reset(const struct phy_sam_gmac_dev *phy) * up to 0.5 s. */ do { - if (retries-- == 0) { + if (retries-- == 0U) { return -ETIMEDOUT; } @@ -223,7 +223,7 @@ int phy_sam_gmac_auto_negotiate(const struct phy_sam_gmac_dev *phy, /* Wait for the auto-negotiation process to complete */ do { - if (retries-- == 0) { + if (retries-- == 0U) { retval = -ETIMEDOUT; goto auto_negotiate_exit; } diff --git a/drivers/flash/flash_gecko.c b/drivers/flash/flash_gecko.c index ba33062b693..8e1f9df23bf 100644 --- a/drivers/flash/flash_gecko.c +++ b/drivers/flash/flash_gecko.c @@ -133,7 +133,7 @@ static bool write_range_is_valid(off_t offset, u32_t size) { return read_range_is_valid(offset, size) && (offset % sizeof(u32_t) == 0) - && (size % 4 == 0); + && (size % 4 == 0U); } static bool read_range_is_valid(off_t offset, u32_t size) diff --git a/drivers/flash/flash_stm32f0x.c b/drivers/flash/flash_stm32f0x.c index 77eb633cf01..d8cdae89249 100644 --- a/drivers/flash/flash_stm32f0x.c +++ b/drivers/flash/flash_stm32f0x.c @@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN); bool flash_stm32_valid_range(struct device *dev, off_t offset, u32_t len, bool write) { - return (!write || (offset % 2 == 0 && len % 2 == 0)) && + return (!write || (offset % 2 == 0 && len % 2 == 0U)) && flash_stm32_range_exists(dev, offset, len); } @@ -134,7 +134,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, { int i, rc = 0; - for (i = 0; i < len; i += 2, offset += 2) { + for (i = 0; i < len; i += 2, offset += 2U) { rc = write_hword(dev, offset, ((const u16_t *) data)[i>>1]); if (rc < 0) { return rc; diff --git a/drivers/flash/flash_stm32f3x.c b/drivers/flash/flash_stm32f3x.c index 0274bb0819d..8cfa2744890 100644 --- a/drivers/flash/flash_stm32f3x.c +++ b/drivers/flash/flash_stm32f3x.c @@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN); bool flash_stm32_valid_range(struct device *dev, off_t offset, u32_t len, bool write) { - return (!write || (offset % 2 == 0 && len % 2 == 0)) && + return (!write || (offset % 2 == 0 && len % 2 == 0U)) && flash_stm32_range_exists(dev, offset, len); } @@ -131,7 +131,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, { int i, rc = 0; - for (i = 0; i < len; i += 2, offset += 2) { + for (i = 0; i < len; i += 2, offset += 2U) { rc = write_hword(dev, offset, ((const u16_t *) data)[i>>1]); if (rc < 0) { return rc; diff --git a/drivers/flash/flash_stm32f7x.c b/drivers/flash/flash_stm32f7x.c index efde9e9a469..58c719f61f5 100644 --- a/drivers/flash/flash_stm32f7x.c +++ b/drivers/flash/flash_stm32f7x.c @@ -77,11 +77,11 @@ static int erase_sector(struct device *dev, u32_t sector) #if defined(FLASH_OPTCR_nDBANK) && FLASH_SECTOR_TOTAL == 24 #if CONFIG_FLASH_SIZE == 2048 if (sector > 11) { - sector += 4; + sector += 4U; } #elif CONFIG_FLASH_SIZE == 1024 if (sector > 7) { - sector += 8; + sector += 8U; } #endif /* CONFIG_FLASH_SIZE */ #endif /* defined(FLASH_OPTCR_nDBANK) && FLASH_SECTOR_TOTAL == 24 */ diff --git a/drivers/flash/flash_stm32l4x.c b/drivers/flash/flash_stm32l4x.c index b56f29a1f28..fc3cbcd3078 100644 --- a/drivers/flash/flash_stm32l4x.c +++ b/drivers/flash/flash_stm32l4x.c @@ -30,7 +30,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN); bool flash_stm32_valid_range(struct device *dev, off_t offset, u32_t len, bool write) { - return (!write || (offset % 8 == 0 && len % 8 == 0)) && + return (!write || (offset % 8 == 0 && len % 8 == 0U)) && flash_stm32_range_exists(dev, offset, len); } @@ -132,7 +132,7 @@ static int erase_page(struct device *dev, unsigned int page) #ifdef FLASH_CR_BKER regs->cr &= ~FLASH_CR_BKER_Msk; /* Select bank, only for DUALBANK devices */ - if (page >= 256) + if (page >= 256U) regs->cr |= FLASH_CR_BKER; #endif regs->cr &= ~FLASH_CR_PNB_Msk; @@ -173,7 +173,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, { int i, rc = 0; - for (i = 0; i < len; i += 8, offset += 8) { + for (i = 0; i < len; i += 8, offset += 8U) { rc = write_dword(dev, offset, UNALIGNED_GET((const u64_t *) data + (i >> 3))); if (rc < 0) { diff --git a/drivers/flash/soc_flash_nios2_qspi.c b/drivers/flash/soc_flash_nios2_qspi.c index 512085a719b..357ce817a83 100644 --- a/drivers/flash/soc_flash_nios2_qspi.c +++ b/drivers/flash/soc_flash_nios2_qspi.c @@ -87,7 +87,7 @@ static int flash_nios2_qspi_erase(struct device *dev, off_t offset, size_t len) for (i = offset/qspi_dev->sector_size; i < qspi_dev->number_of_sectors; i++) { - if ((remaining_length <= 0) || + if ((remaining_length <= 0U) || erase_offset >= (offset + len)) { break; } @@ -280,7 +280,7 @@ static int flash_nios2_qspi_write(struct device *dev, off_t offset, for (i = offset/qspi_dev->sector_size; i < qspi_dev->number_of_sectors; i++) { - if (remaining_length <= 0) { + if (remaining_length <= 0U) { break; } diff --git a/drivers/gpio/gpio_dw.c b/drivers/gpio/gpio_dw.c index 5c3bc19e4a6..00d55897848 100644 --- a/drivers/gpio/gpio_dw.c +++ b/drivers/gpio/gpio_dw.c @@ -139,7 +139,7 @@ static inline int dw_base_to_block_base(u32_t base_addr) } static inline int dw_derive_port_from_base(u32_t base_addr) { - u32_t port = (base_addr & 0x3f) / 12; + u32_t port = (base_addr & 0x3f) / 12U; return port; } static inline int dw_interrupt_support(const struct gpio_dw_config *config) diff --git a/drivers/gpio/gpio_intel_apl.c b/drivers/gpio/gpio_intel_apl.c index c9a186cdd07..771e4f7741e 100644 --- a/drivers/gpio/gpio_intel_apl.c +++ b/drivers/gpio/gpio_intel_apl.c @@ -158,7 +158,7 @@ static int gpio_intel_apl_isr(struct device *dev) reg = cfg->reg_base + REG_GPI_INT_STS_BASE + ((cfg->pin_offset >> 5) << 2); int_sts = sys_read32(reg); - acc_mask = 0; + acc_mask = 0U; SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&data->cb, cb, tmp, node) { cur_mask = int_sts & cb->pin_mask; @@ -220,7 +220,7 @@ static int gpio_intel_apl_config(struct device *dev, int access_op, } /* read in pad configuration register */ - reg = cfg->reg_base + data->pad_base + (raw_pin * 8); + reg = cfg->reg_base + data->pad_base + (raw_pin * 8U); cfg0 = sys_read32(reg); cfg1 = sys_read32(reg + 4); @@ -304,7 +304,7 @@ static int gpio_intel_apl_write(struct device *dev, int access_op, return -EPERM; } - reg = cfg->reg_base + data->pad_base + (raw_pin * 8); + reg = cfg->reg_base + data->pad_base + (raw_pin * 8U); val = sys_read32(reg); if (value) { @@ -340,7 +340,7 @@ static int gpio_intel_apl_read(struct device *dev, int access_op, return -EPERM; } - reg = cfg->reg_base + data->pad_base + (raw_pin * 8); + reg = cfg->reg_base + data->pad_base + (raw_pin * 8U); val = sys_read32(reg); if (!(val & PAD_CFG0_TXDIS)) { diff --git a/drivers/gpio/gpio_mcux.c b/drivers/gpio/gpio_mcux.c index 205ad196608..2a552bda9da 100644 --- a/drivers/gpio/gpio_mcux.c +++ b/drivers/gpio/gpio_mcux.c @@ -49,7 +49,7 @@ static int gpio_mcux_configure(struct device *dev, } /* Check if GPIO port supports interrupts */ - if ((flags & GPIO_INT) && ((config->flags & GPIO_INT) == 0)) { + if ((flags & GPIO_INT) && ((config->flags & GPIO_INT) == 0U)) { return -ENOTSUP; } diff --git a/drivers/gpio/gpio_nrfx.c b/drivers/gpio/gpio_nrfx.c index 3460ac27844..6b2d1d81c17 100644 --- a/drivers/gpio/gpio_nrfx.c +++ b/drivers/gpio/gpio_nrfx.c @@ -105,7 +105,7 @@ static int gpiote_pin_int_cfg(struct device *port, u32_t pin) if (data->double_edge & BIT(pin)) { pol = NRF_GPIOTE_POLARITY_TOGGLE; - } else if (((data->active_level & BIT(pin)) != 0) + } else if (((data->active_level & BIT(pin)) != 0U) ^ ((BIT(pin) & data->inverted) != 0)) { pol = NRF_GPIOTE_POLARITY_LOTOHI; } else { @@ -337,7 +337,7 @@ static void cfg_level_pins(struct device *port) { const struct gpio_nrfx_data *data = get_port_data(port); const struct gpio_nrfx_cfg *cfg = get_port_cfg(port); - u32_t pin = 0; + u32_t pin = 0U; u32_t bit = 1U << pin; u32_t level_pins = get_level_pins(port); @@ -381,7 +381,7 @@ static u32_t check_level_trigger_pins(struct device *port) * they appear to have triggered or not. This ensures * nobody's requesting DETECT. */ - u32_t pin = 0; + u32_t pin = 0U; u32_t bit = 1U << pin; while (level_pins) { @@ -440,7 +440,7 @@ static void gpiote_event_handler(void) nrf_gpiote_event_is_set(evt)) { u32_t abs_pin = nrf_gpiote_event_pin_get(i); /* Divide absolute pin number to port and pin parts. */ - fired_triggers[abs_pin / 32] |= BIT(abs_pin % 32); + fired_triggers[abs_pin / 32U] |= BIT(abs_pin % 32); nrf_gpiote_event_clear(evt); } } diff --git a/drivers/gpio/gpio_rv32m1.c b/drivers/gpio/gpio_rv32m1.c index 24ea5ba6a01..63239b822b2 100644 --- a/drivers/gpio/gpio_rv32m1.c +++ b/drivers/gpio/gpio_rv32m1.c @@ -35,8 +35,8 @@ static int gpio_rv32m1_configure(struct device *dev, GPIO_Type *gpio_base = config->gpio_base; PORT_Type *port_base = config->port_base; port_interrupt_t port_interrupt = 0; - u32_t mask = 0; - u32_t pcr = 0; + u32_t mask = 0U; + u32_t pcr = 0U; u8_t i; /* Check for an invalid pin configuration */ @@ -45,7 +45,7 @@ static int gpio_rv32m1_configure(struct device *dev, } /* Check if GPIO port supports interrupts */ - if ((flags & GPIO_INT) && ((config->flags & GPIO_INT) == 0)) { + if ((flags & GPIO_INT) && ((config->flags & GPIO_INT) == 0U)) { return -EINVAL; } @@ -120,7 +120,7 @@ static int gpio_rv32m1_configure(struct device *dev, port_base->PCR[pin] = (port_base->PCR[pin] & ~mask) | pcr | PORT_PCR_MUX(kPORT_MuxAsGpio); } else { /* GPIO_ACCESS_BY_PORT */ - for (i = 0; i < ARRAY_SIZE(port_base->PCR); i++) { + for (i = 0U; i < ARRAY_SIZE(port_base->PCR); i++) { port_base->PCR[i] = (port_base->PCR[pin] & ~mask) | pcr | PORT_PCR_MUX(kPORT_MuxAsGpio); } @@ -206,7 +206,7 @@ static int gpio_rv32m1_disable_callback(struct device *dev, if (access_op == GPIO_ACCESS_BY_PIN) { data->pin_callback_enables &= ~BIT(pin); } else { - data->pin_callback_enables = 0; + data->pin_callback_enables = 0U; } return 0; diff --git a/drivers/gpio/gpio_sam0.c b/drivers/gpio/gpio_sam0.c index 24b7c0a4d3a..db7081f6cdc 100644 --- a/drivers/gpio/gpio_sam0.c +++ b/drivers/gpio/gpio_sam0.c @@ -87,7 +87,7 @@ static int gpio_sam0_write(struct device *dev, int access_op, u32_t pin, return -ENOTSUP; } - if (value != 0) { + if (value != 0U) { config->regs->OUTSET.bit.OUTSET = mask; } else { config->regs->OUTCLR.bit.OUTCLR = mask; diff --git a/drivers/gpio/gpio_stm32.c b/drivers/gpio/gpio_stm32.c index 90441de246e..8fbd249eb75 100644 --- a/drivers/gpio/gpio_stm32.c +++ b/drivers/gpio/gpio_stm32.c @@ -307,7 +307,7 @@ static int gpio_stm32_write(struct device *dev, int access_op, } pin = stm32_pinval_get(pin); - if (value != 0) { + if (value != 0U) { LL_GPIO_SetOutputPin(gpio, pin); } else { LL_GPIO_ResetOutputPin(gpio, pin); diff --git a/drivers/i2c/i2c_dw.c b/drivers/i2c/i2c_dw.c index d2eef04ff88..61e6997329e 100644 --- a/drivers/i2c/i2c_dw.c +++ b/drivers/i2c/i2c_dw.c @@ -50,7 +50,7 @@ static inline void _i2c_dw_data_ask(struct device *dev) (struct i2c_dw_registers *)dw->base_address; /* No more bytes to request, so command queue is no longer needed */ - if (dw->request_bytes == 0) { + if (dw->request_bytes == 0U) { regs->ic_intr_mask.bits.tx_empty = 0U; return; } @@ -84,7 +84,7 @@ static inline void _i2c_dw_data_ask(struct device *dev) /* After receiving the last byte, send STOP if needed */ if ((dw->xfr_flags & I2C_MSG_STOP) - && (dw->request_bytes == 1)) { + && (dw->request_bytes == 1U)) { data |= IC_DATA_CMD_STOP; } @@ -110,13 +110,13 @@ static void _i2c_dw_data_read(struct device *dev) dw->xfr_len--; dw->rx_pending--; - if (dw->xfr_len == 0) { + if (dw->xfr_len == 0U) { break; } } /* Nothing to receive anymore */ - if (dw->xfr_len == 0) { + if (dw->xfr_len == 0U) { dw->state &= ~I2C_DW_CMD_RECV; return; } @@ -132,7 +132,7 @@ static int _i2c_dw_data_send(struct device *dev) (struct i2c_dw_registers *)dw->base_address; /* Nothing to send anymore, mask the interrupt */ - if (dw->xfr_len == 0) { + if (dw->xfr_len == 0U) { regs->ic_intr_mask.bits.tx_empty = 0U; dw->state &= ~I2C_DW_CMD_SEND; @@ -151,7 +151,7 @@ static int _i2c_dw_data_send(struct device *dev) } /* Send STOP if needed */ - if ((dw->xfr_len == 1) && (dw->xfr_flags & I2C_MSG_STOP)) { + if ((dw->xfr_len == 1U) && (dw->xfr_flags & I2C_MSG_STOP)) { data |= IC_DATA_CMD_STOP; } @@ -253,7 +253,7 @@ static void i2c_dw_isr(void *arg) /* If STOP is not expected, finish processing this * message if there is nothing left to do anymore. */ - if (((dw->xfr_len == 0) + if (((dw->xfr_len == 0U) && !(dw->xfr_flags & I2C_MSG_STOP)) || (ret != 0)) { goto done; @@ -461,7 +461,7 @@ static int i2c_dw_transfer(struct device *dev, } /* Send STOP if this is the last message */ - if (msg_left == 1) { + if (msg_left == 1U) { dw->xfr_flags |= I2C_MSG_STOP; } diff --git a/drivers/i2c/i2c_esp32.c b/drivers/i2c/i2c_esp32.c index fe794e7d0e3..1fd2f112539 100644 --- a/drivers/i2c/i2c_esp32.c +++ b/drivers/i2c/i2c_esp32.c @@ -139,14 +139,14 @@ static int i2c_esp32_configure_speed(const struct i2c_esp32_config *config, return -ENOTSUP; } - period = (APB_CLK_FREQ / freq_hz) / 2; + period = (APB_CLK_FREQ / freq_hz) / 2U; esp32_set_mask32(period << I2C_SCL_LOW_PERIOD_S, I2C_SCL_LOW_PERIOD_REG(config->index)); esp32_set_mask32(period << I2C_SCL_HIGH_PERIOD_S, I2C_SCL_HIGH_PERIOD_REG(config->index)); - period /= 2; /* Set hold and setup times to 1/2th of period */ + period /= 2U; /* Set hold and setup times to 1/2th of period */ esp32_set_mask32(period << I2C_SCL_START_HOLD_TIME_S, I2C_SCL_START_HOLD_REG(config->index)); esp32_set_mask32(period << I2C_SCL_RSTART_SETUP_TIME_S, @@ -156,7 +156,7 @@ static int i2c_esp32_configure_speed(const struct i2c_esp32_config *config, esp32_set_mask32(period << I2C_SCL_STOP_SETUP_TIME_S, I2C_SCL_STOP_SETUP_REG(config->index)); - period /= 2; /* Set sample and hold times to 1/4th of period */ + period /= 2U; /* Set sample and hold times to 1/4th of period */ esp32_set_mask32(period << I2C_SDA_HOLD_TIME_S, I2C_SDA_HOLD_REG(config->index)); esp32_set_mask32(period << I2C_SDA_SAMPLE_TIME_S, @@ -404,7 +404,7 @@ static int i2c_esp32_read_msg(struct device *dev, u16_t addr, * slave device. Divide the read command in two segments as * recommended by the ESP32 Technical Reference Manual. */ - if (msg.len - to_read <= 1) { + if (msg.len - to_read <= 1U) { /* Read the last byte and explicitly ask for an * acknowledgment. */ diff --git a/drivers/i2c/i2c_imx.c b/drivers/i2c/i2c_imx.c index fdc15b577bf..0789607c601 100644 --- a/drivers/i2c/i2c_imx.c +++ b/drivers/i2c/i2c_imx.c @@ -96,7 +96,7 @@ static void i2c_imx_read(struct device *dev, u8_t *rxBuffer, u8_t rxSize) transfer->rxBuff = rxBuffer; transfer->rxSize = rxSize; - if (transfer->rxSize == 1) { + if (transfer->rxSize == 1U) { /* Send Nack */ I2C_SetAckBit(base, false); } else { @@ -194,7 +194,7 @@ static int i2c_imx_transfer(struct device *dev, struct i2c_msg *msgs, while ((I2C_I2SR_REG(base) & i2cStatusBusBusy) && (--timeout)) { } - if (timeout == 0) { + if (timeout == 0U) { return result; } @@ -281,7 +281,7 @@ static void i2c_imx_isr(void *arg) transfer->ack = !(I2C_GetStatusFlag(base, i2cStatusReceivedAck)); - if (transfer->txSize == 0) { + if (transfer->txSize == 0U) { /* Close I2C interrupt. */ I2C_SetIntCmd(base, false); /* Release I2C Bus. */ @@ -294,7 +294,7 @@ static void i2c_imx_isr(void *arg) } } else { /* Normal read operation. */ - if (transfer->rxSize == 2) { + if (transfer->rxSize == 2U) { /* Send Nack */ I2C_SetAckBit(base, false); } else { @@ -302,7 +302,7 @@ static void i2c_imx_isr(void *arg) I2C_SetAckBit(base, true); } - if (transfer->rxSize == 1) { + if (transfer->rxSize == 1U) { /* Switch back to Tx direction to avoid * additional I2C bus read. */ @@ -315,7 +315,7 @@ static void i2c_imx_isr(void *arg) transfer->rxSize--; /* receive finished. */ - if (transfer->rxSize == 0) { + if (transfer->rxSize == 0U) { /* Close I2C interrupt. */ I2C_SetIntCmd(base, false); /* Release I2C Bus. */ diff --git a/drivers/i2c/i2c_ll_stm32.c b/drivers/i2c/i2c_ll_stm32.c index fa37d3e59f1..24c211b6104 100644 --- a/drivers/i2c/i2c_ll_stm32.c +++ b/drivers/i2c/i2c_ll_stm32.c @@ -133,7 +133,7 @@ static int i2c_stm32_transfer(struct device *dev, struct i2c_msg *msg, *next_msg_flags : 0; if (current->len > 255) { - current->len = 255; + current->len = 255U; current->flags &= ~I2C_MSG_STOP; if (next_msg_flags) { *next_msg_flags = current->flags & diff --git a/drivers/i2c/i2c_ll_stm32_v1.c b/drivers/i2c/i2c_ll_stm32_v1.c index b29312e1df7..09ab74a1b69 100644 --- a/drivers/i2c/i2c_ll_stm32_v1.c +++ b/drivers/i2c/i2c_ll_stm32_v1.c @@ -35,7 +35,7 @@ static inline void handle_sb(I2C_TypeDef *i2c, struct i2c_stm32_data *data) slave = (((saddr & 0x0300) >> 7) & 0xFF); u8_t header = slave | HEADER; - if (data->current.is_restart == 0) { + if (data->current.is_restart == 0U) { data->current.is_restart = 1U; } else { header |= I2C_REQUEST_READ; @@ -65,10 +65,10 @@ static inline void handle_addr(I2C_TypeDef *i2c, struct i2c_stm32_data *data) } } if (!data->current.is_write) { - if (data->current.len == 1) { + if (data->current.len == 1U) { /* Single byte reception: enable NACK and clear POS */ LL_I2C_AcknowledgeNextData(i2c, LL_I2C_NACK); - } else if (data->current.len == 2) { + } else if (data->current.len == 2U) { /* 2-byte reception: enable NACK and set POS */ LL_I2C_AcknowledgeNextData(i2c, LL_I2C_NACK); LL_I2C_EnableBitPOS(i2c); @@ -81,7 +81,7 @@ static inline void handle_txe(I2C_TypeDef *i2c, struct i2c_stm32_data *data) { if (data->current.len) { data->current.len--; - if (data->current.len == 0) { + if (data->current.len == 0U) { /* * This is the last byte to transmit disable Buffer * interrupt and wait for a BTF interrupt @@ -431,10 +431,10 @@ s32_t stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, } } - if (len == 1) { + if (len == 1U) { /* Single byte reception: enable NACK and set STOP */ LL_I2C_AcknowledgeNextData(i2c, LL_I2C_NACK); - } else if (len == 2) { + } else if (len == 2U) { /* 2-byte reception: enable NACK and set POS */ LL_I2C_AcknowledgeNextData(i2c, LL_I2C_NACK); LL_I2C_EnableBitPOS(i2c); diff --git a/drivers/i2c/i2c_ll_stm32_v2.c b/drivers/i2c/i2c_ll_stm32_v2.c index 44f6a50ade7..b32e590f3db 100644 --- a/drivers/i2c/i2c_ll_stm32_v2.c +++ b/drivers/i2c/i2c_ll_stm32_v2.c @@ -636,7 +636,7 @@ int stm32_i2c_configure_timing(struct device *dev, u32_t clock) break; } while (presc < 16); - if (presc >= 16) { + if (presc >= 16U) { LOG_DBG("I2C:failed to find prescaler value"); return -EINVAL; } diff --git a/drivers/i2c/i2c_sam_twi.c b/drivers/i2c/i2c_sam_twi.c index f77bc65a451..2e5f538ebe6 100644 --- a/drivers/i2c/i2c_sam_twi.c +++ b/drivers/i2c/i2c_sam_twi.c @@ -83,7 +83,7 @@ static int i2c_clk_set(Twi *const twi, u32_t speed) cl_div = ((SOC_ATMEL_SAM_MCK_FREQ_HZ / (2 * speed)) - 4) / (1 << ck_div); - if (cl_div <= 255) { + if (cl_div <= 255U) { div_completed = true; } else { ck_div++; @@ -168,7 +168,7 @@ static void read_msg_start(Twi *const twi, struct twi_msg *msg, u8_t daddr) twi->TWI_MMR = TWI_MMR_MREAD | TWI_MMR_DADR(daddr); /* In single data byte read the START and STOP must both be set */ - twi_cr_stop = (msg->len == 1) ? TWI_CR_STOP : 0; + twi_cr_stop = (msg->len == 1U) ? TWI_CR_STOP : 0; /* Start the transfer by sending START condition */ twi->TWI_CR = TWI_CR_START | twi_cr_stop; @@ -255,7 +255,7 @@ static void i2c_sam_twi_isr(void *arg) msg->buf[msg->idx++] = twi->TWI_RHR; - if (msg->idx == msg->len - 1) { + if (msg->idx == msg->len - 1U) { /* Send a STOP condition on the TWI */ twi->TWI_CR = TWI_CR_STOP; } diff --git a/drivers/i2c/i2c_sam_twihs.c b/drivers/i2c/i2c_sam_twihs.c index 5388b2bbd67..7fbfe50c6a2 100644 --- a/drivers/i2c/i2c_sam_twihs.c +++ b/drivers/i2c/i2c_sam_twihs.c @@ -83,7 +83,7 @@ static int i2c_clk_set(Twihs *const twihs, u32_t speed) cl_div = ((SOC_ATMEL_SAM_MCK_FREQ_HZ / (2 * speed)) - 3) / (1 << ck_div); - if (cl_div <= 255) { + if (cl_div <= 255U) { div_completed = true; } else { ck_div++; @@ -173,7 +173,7 @@ static void read_msg_start(Twihs *const twihs, struct twihs_msg *msg, twihs->TWIHS_IER = TWIHS_IER_RXRDY | TWIHS_IER_TXCOMP | TWIHS_IER_NACK; /* In single data byte read the START and STOP must both be set */ - twihs_cr_stop = (msg->len == 1) ? TWIHS_CR_STOP : 0; + twihs_cr_stop = (msg->len == 1U) ? TWIHS_CR_STOP : 0; /* Start the transfer by sending START condition */ twihs->TWIHS_CR = TWIHS_CR_START | twihs_cr_stop; } @@ -242,7 +242,7 @@ static void i2c_sam_twihs_isr(void *arg) msg->buf[msg->idx++] = twihs->TWIHS_RHR; - if (msg->idx == msg->len - 1) { + if (msg->idx == msg->len - 1U) { /* Send STOP condition */ twihs->TWIHS_CR = TWIHS_CR_STOP; } diff --git a/drivers/i2c/i2c_sifive.c b/drivers/i2c/i2c_sifive.c index 61771be4987..43d7339a18d 100644 --- a/drivers/i2c/i2c_sifive.c +++ b/drivers/i2c/i2c_sifive.c @@ -77,7 +77,7 @@ static int i2c_sifive_send_addr(struct device *dev, u16_t rw_flag) { const struct i2c_sifive_cfg *config = dev->config->config_info; - u8_t command = 0; + u8_t command = 0U; /* Wait for a previous transfer to complete */ while (i2c_sifive_busy(dev)) @@ -109,7 +109,7 @@ static int i2c_sifive_write_msg(struct device *dev, { const struct i2c_sifive_cfg *config = dev->config->config_info; int rc = 0; - u8_t command = 0; + u8_t command = 0U; rc = i2c_sifive_send_addr(dev, addr, SF_TX_WRITE); if (rc != 0) { @@ -157,7 +157,7 @@ static int i2c_sifive_read_msg(struct device *dev, u16_t addr) { const struct i2c_sifive_cfg *config = dev->config->config_info; - u8_t command = 0; + u8_t command = 0U; i2c_sifive_send_addr(dev, addr, SF_TX_READ); @@ -198,8 +198,8 @@ static int i2c_sifive_read_msg(struct device *dev, static int i2c_sifive_configure(struct device *dev, u32_t dev_config) { const struct i2c_sifive_cfg *config = NULL; - u32_t i2c_speed = 0; - u16_t prescale = 0; + u32_t i2c_speed = 0U; + u16_t prescale = 0U; /* Check for NULL pointers */ if (dev == NULL) { @@ -223,10 +223,10 @@ static int i2c_sifive_configure(struct device *dev, u32_t dev_config) /* Configure bus frequency */ switch (I2C_SPEED_GET(dev_config)) { case I2C_SPEED_STANDARD: - i2c_speed = 100000; /* 100 KHz */ + i2c_speed = 100000U; /* 100 KHz */ break; case I2C_SPEED_FAST: - i2c_speed = 400000; /* 400 KHz */ + i2c_speed = 400000U; /* 400 KHz */ break; case I2C_SPEED_FAST_PLUS: case I2C_SPEED_HIGH: @@ -308,7 +308,7 @@ static int i2c_sifive_transfer(struct device *dev, static int i2c_sifive_init(struct device *dev) { const struct i2c_sifive_cfg *config = dev->config->config_info; - u32_t dev_config = 0; + u32_t dev_config = 0U; int rc = 0; dev_config = (I2C_MODE_MASTER | _i2c_map_dt_bitrate(config->f_bus)); diff --git a/drivers/i2s/i2s_cavs.c b/drivers/i2s/i2s_cavs.c index 717285ba9da..de0d37749d3 100644 --- a/drivers/i2s/i2s_cavs.c +++ b/drivers/i2s/i2s_cavs.c @@ -339,7 +339,7 @@ static int i2s_cavs_configure(struct device *dev, enum i2s_dir dir, return -EINVAL; } - if (i2s_cfg->frame_clk_freq == 0) { + if (i2s_cfg->frame_clk_freq == 0U) { LOG_ERR("Invalid frame_clk_freq %u", i2s_cfg->frame_clk_freq); return -EINVAL; @@ -444,8 +444,8 @@ static int i2s_cavs_configure(struct device *dev, enum i2s_dir dir, * In addition, double M so that it can be later divided by 2 * to get an approximately 50% duty cycle clock */ - i2s_m = (bit_clk_freq << 1) / 100; - i2s_n = mclk / 100; + i2s_m = (bit_clk_freq << 1) / 100U; + i2s_n = mclk / 100U; /* set divider value of 1 which divides the clock by 2 */ mdiv = 1U; @@ -521,7 +521,7 @@ static int i2s_cavs_configure(struct device *dev, enum i2s_dir dir, mn_div->nval = I2S_MNVAL(i2s_n); /* Set up DMA channel parameters */ - word_size_bytes = (word_size_bits + 7) / 8; + word_size_bytes = (word_size_bits + 7) / 8U; dev_data->tx.dma_cfg.source_data_size = word_size_bytes; dev_data->tx.dma_cfg.dest_data_size = word_size_bytes; dev_data->rx.dma_cfg.source_data_size = word_size_bytes; diff --git a/drivers/i2s/i2s_ll_stm32.c b/drivers/i2s/i2s_ll_stm32.c index b83b2957088..121f0fd8ea8 100644 --- a/drivers/i2s/i2s_ll_stm32.c +++ b/drivers/i2s/i2s_ll_stm32.c @@ -33,7 +33,7 @@ LOG_MODULE_REGISTER(i2s_ll_stm32); static unsigned int div_round_closest(u32_t dividend, u32_t divisor) { - return (dividend + (divisor / 2)) / divisor; + return (dividend + (divisor / 2U)) / divisor; } /* @@ -204,7 +204,7 @@ static int i2s_stm32_configure(struct device *dev, enum i2s_dir dir, stream->master = false; } - if (i2s_cfg->frame_clk_freq == 0) { + if (i2s_cfg->frame_clk_freq == 0U) { stream->queue_drop(stream); memset(&stream->cfg, 0, sizeof(struct i2s_config)); stream->state = I2S_STATE_NOT_READY; @@ -223,11 +223,11 @@ static int i2s_stm32_configure(struct device *dev, enum i2s_dir dir, } /* set I2S Data Format */ - if (i2s_cfg->word_size == 16) { + if (i2s_cfg->word_size == 16U) { LL_I2S_SetDataFormat(cfg->i2s, LL_I2S_DATAFORMAT_16B); - } else if (i2s_cfg->word_size == 24) { + } else if (i2s_cfg->word_size == 24U) { LL_I2S_SetDataFormat(cfg->i2s, LL_I2S_DATAFORMAT_24B); - } else if (i2s_cfg->word_size == 32) { + } else if (i2s_cfg->word_size == 32U) { LL_I2S_SetDataFormat(cfg->i2s, LL_I2S_DATAFORMAT_32B); } else { LOG_ERR("invalid word size"); diff --git a/drivers/i2s/i2s_sam_ssc.c b/drivers/i2s/i2s_sam_ssc.c index 5a6fefd8536..9194977d465 100644 --- a/drivers/i2s/i2s_sam_ssc.c +++ b/drivers/i2s/i2s_sam_ssc.c @@ -338,7 +338,7 @@ static int set_rx_data_format(const struct i2s_sam_dev_cfg *const dev_cfg, break; case I2S_FMT_DATA_FORMAT_PCM_LONG: - fslen = num_words * word_size_bits / 2 - 1; + fslen = num_words * word_size_bits / 2U - 1; ssc_rcmr = (pin_rf_en ? SSC_RCMR_START_RF_RISING : 0) | SSC_RCMR_STTDLY(0); @@ -348,7 +348,7 @@ static int set_rx_data_format(const struct i2s_sam_dev_cfg *const dev_cfg, break; case I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED: - fslen = num_words * word_size_bits / 2 - 1; + fslen = num_words * word_size_bits / 2U - 1; ssc_rcmr = SSC_RCMR_CKI | (pin_rf_en ? SSC_RCMR_START_RF_RISING : 0) @@ -377,7 +377,7 @@ static int set_rx_data_format(const struct i2s_sam_dev_cfg *const dev_cfg, * frame period is an odd number set it to be one bit longer. */ ssc_rcmr |= (pin_rf_en ? 0 : SSC_RCMR_START_TRANSMIT) - | SSC_RCMR_PERIOD((num_words * word_size_bits + 1) / 2 - 1); + | SSC_RCMR_PERIOD((num_words * word_size_bits + 1) / 2U - 1); /* Receive Clock Mode Register */ ssc->SSC_RCMR = ssc_rcmr; @@ -426,7 +426,7 @@ static int set_tx_data_format(const struct i2s_sam_dev_cfg *const dev_cfg, break; case I2S_FMT_DATA_FORMAT_PCM_LONG: - fslen = num_words * word_size_bits / 2 - 1; + fslen = num_words * word_size_bits / 2U - 1; ssc_tcmr = SSC_TCMR_CKI | SSC_TCMR_START_TF_RISING @@ -436,7 +436,7 @@ static int set_tx_data_format(const struct i2s_sam_dev_cfg *const dev_cfg, break; case I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED: - fslen = num_words * word_size_bits / 2 - 1; + fslen = num_words * word_size_bits / 2U - 1; ssc_tcmr = SSC_TCMR_START_TF_RISING | SSC_TCMR_STTDLY(0); @@ -457,7 +457,7 @@ static int set_tx_data_format(const struct i2s_sam_dev_cfg *const dev_cfg, ? SSC_TCMR_CKS_TK : SSC_TCMR_CKS_MCK) | ((i2s_cfg->options & I2S_OPT_BIT_CLK_GATED) ? SSC_TCMR_CKO_TRANSFER : SSC_TCMR_CKO_CONTINUOUS) - | SSC_TCMR_PERIOD((num_words * word_size_bits + 1) / 2 - 1); + | SSC_TCMR_PERIOD((num_words * word_size_bits + 1) / 2U - 1); /* Transmit Clock Mode Register */ ssc->SSC_TCMR = ssc_tcmr; @@ -483,19 +483,19 @@ static int set_tx_data_format(const struct i2s_sam_dev_cfg *const dev_cfg, /* Calculate number of bytes required to store a word of bit_size length */ static u8_t get_word_size_bytes(u8_t bit_size) { - u8_t byte_size_min = (bit_size + 7) / 8; + u8_t byte_size_min = (bit_size + 7) / 8U; u8_t byte_size; - byte_size = (byte_size_min == 3) ? 4 : byte_size_min; + byte_size = (byte_size_min == 3U) ? 4 : byte_size_min; return byte_size; } static int bit_clock_set(Ssc *const ssc, u32_t bit_clk_freq) { - u32_t clk_div = SOC_ATMEL_SAM_MCK_FREQ_HZ / bit_clk_freq / 2; + u32_t clk_div = SOC_ATMEL_SAM_MCK_FREQ_HZ / bit_clk_freq / 2U; - if (clk_div == 0 || clk_div >= (1 << 12)) { + if (clk_div == 0U || clk_div >= (1 << 12)) { LOG_ERR("Invalid bit clock frequency"); return -EINVAL; } @@ -554,7 +554,7 @@ static int i2s_sam_configure(struct device *dev, enum i2s_dir dir, return -EINVAL; } - if (i2s_cfg->frame_clk_freq == 0) { + if (i2s_cfg->frame_clk_freq == 0U) { stream->queue_drop(stream); (void)memset(&stream->cfg, 0, sizeof(struct i2s_config)); stream->state = I2S_STATE_NOT_READY; diff --git a/drivers/ieee802154/ieee802154_cc1200.c b/drivers/ieee802154/ieee802154_cc1200.c index de51e41dd7c..b549b0bfcc4 100644 --- a/drivers/ieee802154/ieee802154_cc1200.c +++ b/drivers/ieee802154/ieee802154_cc1200.c @@ -282,7 +282,7 @@ static u32_t rf_evaluate_freq_setting(struct cc1200_context *ctx, u32_t chan) u32_t rf, lo_div; rf = ctx->rf_settings->chan_center_freq0 + - ((chan * (u32_t)ctx->rf_settings->channel_spacing) / 10); + ((chan * (u32_t)ctx->rf_settings->channel_spacing) / 10U); lo_div = get_lo_divider(ctx); LOG_DBG("Calculating freq for %u KHz RF (%u)", rf, lo_div); @@ -298,23 +298,23 @@ static u32_t rf_evaluate_freq_setting(struct cc1200_context *ctx, u32_t chan) } if (hz < 1000) { - freq_tmp = (hz * lo_div * 65536) / xtal; + freq_tmp = (hz * lo_div * 65536U) / xtal; } else { - freq_tmp = ((hz * lo_div) / xtal) * 65536; + freq_tmp = ((hz * lo_div) / xtal) * 65536U; } rst = freq_tmp % factor; freq_tmp /= factor; - if (factor > 1 && (rst/(factor/10)) > 5) { + if (factor > 1 && (rst/(factor/10U)) > 5) { freq_tmp++; } freq += freq_tmp; - factor *= 10; - mult_10 /= 10; - xtal /= 10; + factor *= 10U; + mult_10 /= 10U; + xtal /= 10U; rf -= hz; } @@ -751,7 +751,7 @@ static int configure_spi(struct device *dev) } cs_ctrl.gpio_pin = DT_IEEE802154_CC1200_GPIO_SPI_CS_PIN; - cs_ctrl.delay = 0; + cs_ctrl.delay = 0U; cc1200->spi_cfg.cs = &cs_ctrl; diff --git a/drivers/ieee802154/ieee802154_cc2520.c b/drivers/ieee802154/ieee802154_cc2520.c index a787d73fb4a..e99332e53df 100644 --- a/drivers/ieee802154/ieee802154_cc2520.c +++ b/drivers/ieee802154/ieee802154_cc2520.c @@ -574,12 +574,12 @@ static inline void insert_radio_noise_details(struct net_pkt *pkt, u8_t *buf) * lqi = (lqi - 50) * 4 */ lqi = buf[1] & CC2520_FCS_CORRELATION; - if (lqi <= 50) { + if (lqi <= 50U) { lqi = 0U; - } else if (lqi >= 110) { + } else if (lqi >= 110U) { lqi = 255U; } else { - lqi = (lqi - 50) << 2; + lqi = (lqi - 50U) << 2; } net_pkt_set_ieee802154_lqi(pkt, lqi); @@ -645,7 +645,7 @@ static void cc2520_rx(int arg) } if (!IS_ENABLED(CONFIG_IEEE802154_RAW_MODE)) { - pkt_len -= 2; + pkt_len -= 2U; } if (!read_rxfifo_content(cc2520, pkt->buffer, pkt_len)) { @@ -992,7 +992,7 @@ static inline int configure_spi(struct device *dev) } cs_ctrl.gpio_pin = DT_TI_CC2520_0_CS_GPIO_PIN; - cs_ctrl.delay = 0; + cs_ctrl.delay = 0U; cc2520->spi_cfg.cs = &cs_ctrl; @@ -1375,7 +1375,7 @@ static int cc2520_crypto_begin_session(struct device *dev, return -EINVAL; } - if (ctx->mode_params.ccm_info.nonce_len != 13) { + if (ctx->mode_params.ccm_info.nonce_len != 13U) { LOG_ERR("Nonce length erroneous (%u)", ctx->mode_params.ccm_info.nonce_len); return -EINVAL; diff --git a/drivers/ieee802154/ieee802154_kw41z.c b/drivers/ieee802154/ieee802154_kw41z.c index 011e40ee732..b916a9267ab 100644 --- a/drivers/ieee802154/ieee802154_kw41z.c +++ b/drivers/ieee802154/ieee802154_kw41z.c @@ -465,7 +465,7 @@ static int kw41z_stop(struct device *dev) static u8_t kw41z_convert_lqi(u8_t hw_lqi) { - if (hw_lqi >= 220) { + if (hw_lqi >= 220U) { return 255; } else { return (51 * hw_lqi) / 44; @@ -502,8 +502,8 @@ static inline void kw41z_rx(struct kw41z_context *kw41z, u8_t len) #if CONFIG_SOC_MKW41Z4 /* PKT_BUFFER_RX needs to be accessed aligned to 16 bits */ for (u16_t reg_val = 0, i = 0; i < pkt_len; i++) { - if (i % 2 == 0) { - reg_val = ZLL->PKT_BUFFER_RX[i/2]; + if (i % 2 == 0U) { + reg_val = ZLL->PKT_BUFFER_RX[i/2U]; buf->data[i] = reg_val & 0xFF; } else { buf->data[i] = reg_val >> 8; @@ -514,7 +514,7 @@ static inline void kw41z_rx(struct kw41z_context *kw41z, u8_t len) for (u32_t reg_val = 0, i = 0; i < pkt_len; i++) { switch (i % 4) { case 0: - reg_val = ZLL->PKT_BUFFER[i/4]; + reg_val = ZLL->PKT_BUFFER[i/4U]; buf->data[i] = reg_val & 0xFF; break; case 1: @@ -704,7 +704,7 @@ static void kw41z_isr(int unused) * frame, 1 frame length, 2 frame control, * 1 sequence, 2 FCS. Times two to convert to symbols. */ - rx_len = rx_len * 2 + 12 + 22 + 2; + rx_len = rx_len * 2U + 12 + 22 + 2; kw41z_tmr3_set_timeout(rx_len); } restart_rx = 0U; @@ -765,7 +765,7 @@ static void kw41z_isr(int unused) ZLL_IRQSTS_RX_FRAME_LENGTH_SHIFT; if (irqsts & ZLL_IRQSTS_RXIRQ_MASK) { - if (rx_len != 0) { + if (rx_len != 0U) { kw41z_rx(&kw41z_context_data, rx_len); } diff --git a/drivers/ieee802154/ieee802154_mcr20a.c b/drivers/ieee802154/ieee802154_mcr20a.c index 4f095797bb2..da6c767eafa 100644 --- a/drivers/ieee802154/ieee802154_mcr20a.c +++ b/drivers/ieee802154/ieee802154_mcr20a.c @@ -920,7 +920,7 @@ static int mcr20a_set_channel(struct device *dev, u16_t channel) } LOG_DBG("%u", channel); - channel -= 11; + channel -= 11U; buf[0] = set_bits_pll_int0_val(pll_int_lt[channel]); buf[1] = (u8_t)pll_frac_lt[channel]; buf[2] = (u8_t)(pll_frac_lt[channel] >> 8); @@ -1387,7 +1387,7 @@ static inline int configure_spi(struct device *dev) } mcr20a->cs_ctrl.gpio_pin = DT_NXP_MCR20A_0_CS_GPIO_PIN; - mcr20a->cs_ctrl.delay = 0; + mcr20a->cs_ctrl.delay = 0U; mcr20a->spi_cfg.cs = &mcr20a->cs_ctrl; diff --git a/drivers/interrupt_controller/loapic_intr.c b/drivers/interrupt_controller/loapic_intr.c index 0952dad2b43..76523d4f48f 100644 --- a/drivers/interrupt_controller/loapic_intr.c +++ b/drivers/interrupt_controller/loapic_intr.c @@ -442,7 +442,7 @@ static int loapic_suspend(struct device *port) */ lvt = LOAPIC_READ(LOAPIC_TIMER + (loapic_irq * 0x10)); - if ((lvt & LOAPIC_LVT_MASKED) == 0) { + if ((lvt & LOAPIC_LVT_MASKED) == 0U) { sys_bitfield_set_bit((mem_addr_t)loapic_suspend_buf, loapic_irq); } diff --git a/drivers/interrupt_controller/mvic.c b/drivers/interrupt_controller/mvic.c index 39b4ccfec1b..9ebe08e2e40 100644 --- a/drivers/interrupt_controller/mvic.c +++ b/drivers/interrupt_controller/mvic.c @@ -188,7 +188,7 @@ void __irq_controller_irq_config(unsigned int vector, unsigned int irq, if (irq != CONFIG_MVIC_TIMER_IRQ) { _mvic_rte_set(irq, MVIC_IOWIN_MASK | flags); } else { - __ASSERT(flags == 0, + __ASSERT(flags == 0U, "Timer interrupt cannot have triggering flags set"); } } diff --git a/drivers/interrupt_controller/plic.c b/drivers/interrupt_controller/plic.c index 3874a58dcf0..845890b0f59 100644 --- a/drivers/interrupt_controller/plic.c +++ b/drivers/interrupt_controller/plic.c @@ -160,7 +160,7 @@ static void plic_irq_handler(void *arg) * If the IRQ is out of range, call z_irq_spurious. * A call to z_irq_spurious will not return. */ - if (irq == 0 || irq >= PLIC_IRQS) + if (irq == 0U || irq >= PLIC_IRQS) z_irq_spurious(NULL); irq += RISCV_MAX_GENERIC_IRQ; diff --git a/drivers/interrupt_controller/shared_irq.c b/drivers/interrupt_controller/shared_irq.c index a3968da05bc..7af6a334849 100644 --- a/drivers/interrupt_controller/shared_irq.c +++ b/drivers/interrupt_controller/shared_irq.c @@ -52,7 +52,7 @@ static inline int enable(struct device *dev, struct device *isr_dev) for (i = 0U; i < config->client_count; i++) { if (clients->client[i].isr_dev == isr_dev) { - clients->client[i].enabled = 1; + clients->client[i].enabled = 1U; irq_enable(config->irq_num); return 0; } @@ -84,7 +84,7 @@ static inline int disable(struct device *dev, struct device *isr_dev) for (i = 0U; i < config->client_count; i++) { if (clients->client[i].isr_dev == isr_dev) { - clients->client[i].enabled = 0; + clients->client[i].enabled = 0U; if (last_enabled_isr(clients, config->client_count)) { irq_disable(config->irq_num); } diff --git a/drivers/led/lp3943.c b/drivers/led/lp3943.c index 3a253384ebc..e503217cf40 100644 --- a/drivers/led/lp3943.c +++ b/drivers/led/lp3943.c @@ -76,7 +76,7 @@ static int lp3943_get_led_reg(u32_t *led, u8_t *reg) /* Fall through */ case 7: *reg = LP3943_LS1; - *led -= 4; + *led -= 4U; break; case 8: case 9: @@ -84,7 +84,7 @@ static int lp3943_get_led_reg(u32_t *led, u8_t *reg) /* Fall through */ case 11: *reg = LP3943_LS2; - *led -= 8; + *led -= 8U; break; case 12: case 13: @@ -92,7 +92,7 @@ static int lp3943_get_led_reg(u32_t *led, u8_t *reg) /* Fall through */ case 15: *reg = LP3943_LS3; - *led -= 12; + *led -= 12U; break; default: LOG_ERR("Invalid LED specified"); @@ -151,7 +151,7 @@ static int lp3943_led_blink(struct device *dev, u32_t led, reg = LP3943_PSC1; } - val = (period * 255) / dev_data->max_period; + val = (period * 255U) / dev_data->max_period; if (i2c_reg_write_byte(data->i2c, CONFIG_LP3943_I2C_ADDRESS, reg, val)) { LOG_ERR("LED write failed"); @@ -192,7 +192,7 @@ static int lp3943_led_set_brightness(struct device *dev, u32_t led, reg = LP3943_PWM1; } - val = (value * 255) / dev_data->max_brightness; + val = (value * 255U) / dev_data->max_brightness; if (i2c_reg_write_byte(data->i2c, CONFIG_LP3943_I2C_ADDRESS, reg, val)) { LOG_ERR("LED write failed"); diff --git a/drivers/led/pca9633.c b/drivers/led/pca9633.c index 0ff81226c5e..d0f6cdd3a90 100644 --- a/drivers/led/pca9633.c +++ b/drivers/led/pca9633.c @@ -70,7 +70,7 @@ static int pca9633_led_blink(struct device *dev, u32_t led, * (time_on / period) = (GDC / 256) -> * GDC = ((time_on * 256) / period) */ - gdc = delay_on * 256 / period; + gdc = delay_on * 256U / period; if (i2c_reg_write_byte(data->i2c, CONFIG_PCA9633_I2C_ADDRESS, PCA9633_GRPPWM, gdc)) { @@ -84,7 +84,7 @@ static int pca9633_led_blink(struct device *dev, u32_t led, * So, period (in ms) = (((GFRQ + 1) / 24) * 1000) -> * GFRQ = ((period * 24 / 1000) - 1) */ - gfrq = (period * 24 / 1000) - 1; + gfrq = (period * 24U / 1000) - 1; if (i2c_reg_write_byte(data->i2c, CONFIG_PCA9633_I2C_ADDRESS, PCA9633_GRPFREQ, gfrq)) { @@ -126,7 +126,7 @@ static int pca9633_led_set_brightness(struct device *dev, u32_t led, } /* Set the LED brightness value */ - val = (value * 255) / dev_data->max_brightness; + val = (value * 255U) / dev_data->max_brightness; if (i2c_reg_write_byte(data->i2c, CONFIG_PCA9633_I2C_ADDRESS, PCA9633_PWM_BASE + led, val)) { diff --git a/drivers/neural_net/intel_gna.c b/drivers/neural_net/intel_gna.c index 0527130938f..74f0288d9fa 100644 --- a/drivers/neural_net/intel_gna.c +++ b/drivers/neural_net/intel_gna.c @@ -90,13 +90,13 @@ static void intel_gna_interrupt_handler(struct device *dev) pending_resp.response.output_len = pending_req.output_len; pending_resp.callback = pending_req.callback; - pending_resp.response.stats.cycles_per_sec = 200000000; + pending_resp.response.stats.cycles_per_sec = 200000000U; if (regs->gnasts & GNA_STS_STATS_VALID) { pending_resp.response.stats.total_cycles = regs->gnaptc; pending_resp.response.stats.stall_cycles = regs->gnasc; } else { - pending_resp.response.stats.total_cycles = 0; - pending_resp.response.stats.stall_cycles = 0; + pending_resp.response.stats.total_cycles = 0U; + pending_resp.response.stats.stall_cycles = 0U; } k_msgq_put(&gna->response_queue, &pending_resp, K_NO_WAIT); diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 4a4ef05a552..0ea3d14fd98 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -142,7 +142,7 @@ static int pci_bar_config_get(union pci_addr_reg pci_ctrl_addr, u32_t *config) sizeof(old_value), old_value); /* check if this BAR is implemented */ - if (*config != 0xffffffff && *config != 0) { + if (*config != 0xffffffff && *config != 0U) { return 0; } @@ -201,7 +201,7 @@ static int pci_bar_params_get(union pci_addr_reg pci_ctrl_addr, dev_info->addr = bar_value & mask; addr = bar_config & mask; - if (addr != 0) { + if (addr != 0U) { /* calculate the size of the BAR memory required */ dev_info->size = 1 << (find_lsb_set(addr) - 1); } diff --git a/drivers/pci/pci_config.c b/drivers/pci/pci_config.c index 75b8aa138f2..1988ad26e11 100644 --- a/drivers/pci/pci_config.c +++ b/drivers/pci/pci_config.c @@ -41,7 +41,7 @@ void pci_config_out_long(u32_t bus_no, u32_t device_no, u32_t func_no, pci_addr.field.bus = bus_no; pci_addr.field.device = device_no; pci_addr.field.func = func_no; - pci_addr.field.reg = offset / 4; + pci_addr.field.reg = offset / 4U; pci_addr.field.offset = 0; /* write to the PCI controller */ @@ -71,7 +71,7 @@ void pci_config_out_word(u32_t bus_no, u32_t device_no, u32_t func_no, pci_addr.field.bus = bus_no; pci_addr.field.device = device_no; pci_addr.field.func = func_no; - pci_addr.field.reg = offset / 4; + pci_addr.field.reg = offset / 4U; pci_addr.field.offset = offset & 2; /* write to the PCI controller */ @@ -101,7 +101,7 @@ void pci_config_out_byte(u32_t bus_no, u32_t device_no, u32_t func_no, pci_addr.field.bus = bus_no; pci_addr.field.device = device_no; pci_addr.field.func = func_no; - pci_addr.field.reg = offset / 4; + pci_addr.field.reg = offset / 4U; pci_addr.field.offset = offset % 4; /* write to the PCI controller */ @@ -132,7 +132,7 @@ void pci_config_in_long(u32_t bus_no, u32_t device_no, u32_t func_no, pci_addr.field.bus = bus_no; pci_addr.field.device = device_no; pci_addr.field.func = func_no; - pci_addr.field.reg = offset / 4; + pci_addr.field.reg = offset / 4U; pci_addr.field.offset = 0; /* read from the PCI controller */ @@ -165,7 +165,7 @@ void pci_config_in_word(u32_t bus_no, u32_t device_no, u32_t func_no, pci_addr.field.bus = bus_no; pci_addr.field.device = device_no; pci_addr.field.func = func_no; - pci_addr.field.reg = offset / 4; + pci_addr.field.reg = offset / 4U; pci_addr.field.offset = offset & 2; /* read from the PCI controller */ @@ -202,7 +202,7 @@ void pci_config_in_byte(u32_t bus_no, u32_t device_no, u32_t func_no, pci_addr.field.bus = bus_no; pci_addr.field.device = device_no; pci_addr.field.func = func_no; - pci_addr.field.reg = offset / 4; + pci_addr.field.reg = offset / 4U; pci_addr.field.offset = offset % 4; /* read from the PCI controller */ @@ -245,7 +245,7 @@ int pci_config_ext_cap_ptr_find(u8_t ext_cap_find_id, u32_t bus, pci_config_in_word(bus, device, function, PCI_CFG_STATUS, &tmp_stat); - if ((tmp_stat & PCI_STATUS_NEW_CAP) == 0) { + if ((tmp_stat & PCI_STATUS_NEW_CAP) == 0U) { return -1; } diff --git a/drivers/pci/pci_legacy_bridge.c b/drivers/pci/pci_legacy_bridge.c index 0411b7657c0..515d4f7a317 100644 --- a/drivers/pci/pci_legacy_bridge.c +++ b/drivers/pci/pci_legacy_bridge.c @@ -69,7 +69,7 @@ static int pci_rcba_mask_get(union pci_addr_reg pci_ctrl_addr, old_value); /* check if this RCBA is implemented */ - if (*mask != 0xffffffff && *mask != 0) { + if (*mask != 0xffffffff && *mask != 0U) { /* clear the least address unrelated bit */ *mask &= ~0x01; return 0; @@ -99,13 +99,13 @@ int pci_legacy_bridge_detect(struct pci_dev_info *dev_info) u32_t rcba_mask; /* bits set for RCBA */ /* initialise the PCI controller address register value */ - pci_ctrl_addr.value = 0; + pci_ctrl_addr.value = 0U; pci_ctrl_addr.field.bus = CONFIG_PCI_LEGACY_BRIDGE_BUS; pci_ctrl_addr.field.device = CONFIG_PCI_LEGACY_BRIDGE_DEV; /* verify first if there is a valid device at this point */ - pci_ctrl_addr.field.func = 0; + pci_ctrl_addr.field.func = 0U; pci_read(DEFAULT_PCI_CONTROLLER, pci_ctrl_addr, @@ -139,7 +139,7 @@ int pci_legacy_bridge_detect(struct pci_dev_info *dev_info) } dev_info->addr = rcba & rcba_mask; - if (dev_info->addr != 0) { + if (dev_info->addr != 0U) { /* calculate the size of the root complex memory required */ dev_info->size = 1 << (find_lsb_set(rcba_mask) - 1); } @@ -147,10 +147,10 @@ int pci_legacy_bridge_detect(struct pci_dev_info *dev_info) dev_info->irq = -1; dev_info->bus = CONFIG_PCI_LEGACY_BRIDGE_BUS; dev_info->dev = CONFIG_PCI_LEGACY_BRIDGE_DEV; - dev_info->function = 0; + dev_info->function = 0U; dev_info->mem_type = BAR_SPACE_MEM; dev_info->class_type = pci_dev_header.field.class; - dev_info->bar = 0; + dev_info->bar = 0U; dev_info->vendor_id = pci_dev_header.field.vendor_id; dev_info->device_id = pci_dev_header.field.device_id; diff --git a/drivers/pinmux/pinmux_esp32.c b/drivers/pinmux/pinmux_esp32.c index 7ead3602448..a796e59b004 100644 --- a/drivers/pinmux/pinmux_esp32.c +++ b/drivers/pinmux/pinmux_esp32.c @@ -132,7 +132,7 @@ static int pinmux_input(struct device *dev, u32_t pin, u8_t func) if (func == PINMUX_INPUT_ENABLED) { reg = (u32_t *)(DR_REG_GPIO_BASE + line[0]); } else if (func == PINMUX_OUTPUT_ENABLED) { - if (pin >= 34 && pin <= 39) { + if (pin >= 34U && pin <= 39U) { /* These pins are input only */ return -EINVAL; } diff --git a/drivers/pinmux/pinmux_sam0.c b/drivers/pinmux/pinmux_sam0.c index 30093386c55..a96395de4a7 100644 --- a/drivers/pinmux/pinmux_sam0.c +++ b/drivers/pinmux/pinmux_sam0.c @@ -15,7 +15,7 @@ static int pinmux_sam0_set(struct device *dev, u32_t pin, u32_t func) { const struct pinmux_sam0_config *cfg = dev->config->config_info; bool odd_pin = pin & 1; - int idx = pin / 2; + int idx = pin / 2U; /* Each pinmux register holds the config for two pins. The * even numbered pin goes in the bits 0..3 and the odd @@ -35,7 +35,7 @@ static int pinmux_sam0_get(struct device *dev, u32_t pin, u32_t *func) { const struct pinmux_sam0_config *cfg = dev->config->config_info; bool odd_pin = pin & 1; - int idx = pin / 2; + int idx = pin / 2U; if (odd_pin) { *func = cfg->regs->PMUX[idx].bit.PMUXO; diff --git a/drivers/pwm/pwm_dw.c b/drivers/pwm/pwm_dw.c index 801a191ef9a..9ee15cbe3bd 100644 --- a/drivers/pwm/pwm_dw.c +++ b/drivers/pwm/pwm_dw.c @@ -105,7 +105,7 @@ static int __set_one_port(struct device *dev, u32_t pwm, /* Disable timer to prevent any output */ sys_write32(TIMER_INIT_CTRL, (reg_addr + REG_TMR_CTRL)); - if ((off == 0) || (on == 0)) { + if ((off == 0U) || (on == 0U)) { /* stop PWM if so specified */ return 0; } @@ -151,13 +151,13 @@ static int pwm_dw_pin_set_cycles(struct device *dev, return -EIO; } - if (period_cycles == 0 || pulse_cycles > period_cycles) { + if (period_cycles == 0U || pulse_cycles > period_cycles) { return -EINVAL; } on = pulse_cycles; off = period_cycles - pulse_cycles; - if (off == 0) { + if (off == 0U) { on--; off++; } diff --git a/drivers/pwm/pwm_imx.c b/drivers/pwm/pwm_imx.c index 4de819f2519..d1d1b810338 100644 --- a/drivers/pwm/pwm_imx.c +++ b/drivers/pwm/pwm_imx.c @@ -63,7 +63,7 @@ static int imx_pwm_pin_set(struct device *dev, u32_t pwm, u32_t cr, sr; - if ((period_cycles == 0) || (pulse_cycles > period_cycles)) { + if ((period_cycles == 0U) || (pulse_cycles > period_cycles)) { LOG_ERR("Invalid combination: period_cycles=%d, " "pulse_cycles=%d", period_cycles, pulse_cycles); return -EINVAL; @@ -112,7 +112,7 @@ static int imx_pwm_pin_set(struct device *dev, u32_t pwm, * PERIOD value in PWMPR plus 2. */ if (period_cycles > 2) { - period_cycles -= 2; + period_cycles -= 2U; } else { return -EINVAL; } diff --git a/drivers/pwm/pwm_mcux_ftm.c b/drivers/pwm/pwm_mcux_ftm.c index 7a339da0775..5b445f89b6f 100644 --- a/drivers/pwm/pwm_mcux_ftm.c +++ b/drivers/pwm/pwm_mcux_ftm.c @@ -37,7 +37,7 @@ static int mcux_ftm_pin_set(struct device *dev, u32_t pwm, struct mcux_ftm_data *data = dev->driver_data; u8_t duty_cycle; - if ((period_cycles == 0) || (pulse_cycles > period_cycles)) { + if ((period_cycles == 0U) || (pulse_cycles > period_cycles)) { LOG_ERR("Invalid combination: period_cycles=%d, " "pulse_cycles=%d", period_cycles, pulse_cycles); return -EINVAL; @@ -71,7 +71,7 @@ static int mcux_ftm_pin_set(struct device *dev, u32_t pwm, LOG_DBG("pwm_freq=%d, clock_freq=%d", pwm_freq, clock_freq); - if (pwm_freq == 0) { + if (pwm_freq == 0U) { LOG_ERR("Could not set up pwm_freq=%d", pwm_freq); return -EINVAL; } diff --git a/drivers/pwm/pwm_nrf5_sw.c b/drivers/pwm/pwm_nrf5_sw.c index b300da97599..8858b793d88 100644 --- a/drivers/pwm/pwm_nrf5_sw.c +++ b/drivers/pwm/pwm_nrf5_sw.c @@ -47,14 +47,14 @@ static u32_t pwm_period_check(struct pwm_data *data, u8_t map_size, u8_t i; /* allow 0% and 100% duty cycle, as it does not use PWM. */ - if ((pulse_cycles == 0) || (pulse_cycles == period_cycles)) { + if ((pulse_cycles == 0U) || (pulse_cycles == period_cycles)) { return 0; } /* fail if requested period does not match already running period */ for (i = 0U; i < map_size; i++) { if ((data->map[i].pwm != pwm) && - (data->map[i].pulse_cycles != 0) && + (data->map[i].pulse_cycles != 0U) && (period_cycles != data->period_cycles)) { return -EINVAL; } @@ -78,7 +78,7 @@ static u8_t pwm_channel_map(struct pwm_data *data, u8_t map_size, /* find a free entry */ i = map_size; while (i--) { - if (data->map[i].pulse_cycles == 0) { + if (data->map[i].pulse_cycles == 0U) { break; } } @@ -130,7 +130,7 @@ static int pwm_nrf5_sw_pin_set(struct device *dev, u32_t pwm, /* configure GPIO pin as output */ NRF_GPIO->DIRSET = BIT(pwm); - if (pulse_cycles == 0) { + if (pulse_cycles == 0U) { /* 0% duty cycle, keep pin low */ NRF_GPIO->OUTCLR = BIT(pwm); diff --git a/drivers/pwm/pwm_nrfx.c b/drivers/pwm/pwm_nrfx.c index 26702cb6a9e..51becefd9f9 100644 --- a/drivers/pwm/pwm_nrfx.c +++ b/drivers/pwm/pwm_nrfx.c @@ -85,7 +85,7 @@ static u32_t pwm_period_check_and_set(const struct pwm_nrfx_config *config, /* If period_cycles fit with standard prescaler, * set it directly */ - data->prescaler = 1; + data->prescaler = 1U; data->countertop = period_cycles; data->period_cycles = period_cycles; } @@ -104,7 +104,7 @@ static u8_t pwm_channel_map(const uint8_t *output_pins, u32_t pwm) u8_t i; /* Find pin, return channel number */ - for (i = 0; i < NRF_PWM_CHANNEL_COUNT; i++) { + for (i = 0U; i < NRF_PWM_CHANNEL_COUNT; i++) { if (output_pins[i] != NRFX_PWM_PIN_NOT_USED && (pwm == (output_pins[i] & PWM_NRFX_CH_PIN_MASK))) { return i; @@ -119,7 +119,7 @@ static bool any_channel_active(const struct pwm_nrfx_data *data) { u8_t channel; - for (channel = 0; channel < NRF_PWM_CHANNEL_COUNT; channel++) { + for (channel = 0U; channel < NRF_PWM_CHANNEL_COUNT; channel++) { u16_t channel_pulse_cycle = data->current[channel] & PWM_NRFX_CH_PULSE_CYCLES_MASK; @@ -182,7 +182,7 @@ static int pwm_nrfx_pin_set(struct device *dev, u32_t pwm, * since this will the setting if we in the future disable the * peripheral when no channels are active. */ - if (pulse_cycles == 0 || pulse_cycles == period_cycles) { + if (pulse_cycles == 0U || pulse_cycles == period_cycles) { /* If pulse 0% and pin not inverted, set LOW. * If pulse 100% and pin inverted, set LOW. * If pulse 0% and pin inverted, set HIGH. @@ -193,7 +193,7 @@ static int pwm_nrfx_pin_set(struct device *dev, u32_t pwm, & NRFX_PWM_PIN_INVERTED; bool pulse_0_and_not_inverted = - (pulse_cycles == 0) + (pulse_cycles == 0U) && !channel_inverted_state; bool pulse_100_and_inverted = (pulse_cycles == period_cycles) diff --git a/drivers/pwm/pwm_pca9685.c b/drivers/pwm/pwm_pca9685.c index 33020c0d295..79a18b762db 100644 --- a/drivers/pwm/pwm_pca9685.c +++ b/drivers/pwm/pwm_pca9685.c @@ -89,7 +89,7 @@ static int pwm_pca9685_pin_set_cycles(struct device *dev, u32_t pwm, buf[2] = (1 << 4); buf[3] = 0x0; buf[4] = 0x0; - } else if (pulse_count == 0) { + } else if (pulse_count == 0U) { buf[1] = 0x0; buf[2] = 0x0; buf[3] = 0x0; diff --git a/drivers/pwm/pwm_qmsi.c b/drivers/pwm/pwm_qmsi.c index f65c96ba53a..73909d4a3af 100644 --- a/drivers/pwm/pwm_qmsi.c +++ b/drivers/pwm/pwm_qmsi.c @@ -70,7 +70,7 @@ static int __set_one_port(struct device *dev, qm_pwm_t id, u32_t pwm, /* Disable timer to prevent any output */ qm_pwm_stop(id, pwm); - if (on == 0) { + if (on == 0U) { /* stop PWM if so specified */ goto pwm_set_port_return; } @@ -79,7 +79,7 @@ static int __set_one_port(struct device *dev, qm_pwm_t id, u32_t pwm, * off period must be more than zero. Otherwise, the PWM pin will be * turned off. Let's use the minimum value which is 1 for this case. */ - if (off == 0) { + if (off == 0U) { off = 1U; } @@ -136,7 +136,7 @@ static int pwm_qmsi_pin_set(struct device *dev, u32_t pwm, return -EINVAL; } - if (period_cycles == 0 || pulse_cycles > period_cycles) { + if (period_cycles == 0U || pulse_cycles > period_cycles) { return -EINVAL; } @@ -147,7 +147,7 @@ static int pwm_qmsi_pin_set(struct device *dev, u32_t pwm, * low must be more than zero. Otherwise, the PWM pin will be * turned off. Let's make sure low is always more than zero. */ - if (low == 0) { + if (low == 0U) { high--; low = 1U; } diff --git a/drivers/pwm/pwm_sam.c b/drivers/pwm/pwm_sam.c index 80bb26e962d..4490cff0bf4 100644 --- a/drivers/pwm/pwm_sam.c +++ b/drivers/pwm/pwm_sam.c @@ -44,7 +44,7 @@ static int sam_pwm_pin_set(struct device *dev, u32_t ch, return -EINVAL; } - if (period_cycles == 0 || pulse_cycles > period_cycles) { + if (period_cycles == 0U || pulse_cycles > period_cycles) { return -EINVAL; } diff --git a/drivers/pwm/pwm_sifive.c b/drivers/pwm/pwm_sifive.c index 15c71a38d45..7b67f749024 100644 --- a/drivers/pwm/pwm_sifive.c +++ b/drivers/pwm/pwm_sifive.c @@ -99,9 +99,9 @@ static int pwm_sifive_pin_set(struct device *dev, u32_t pulse_cycles) { const struct pwm_sifive_cfg *config = NULL; - u32_t count_max = 0; - u32_t max_cmp_val = 0; - u32_t pwmscale = 0; + u32_t count_max = 0U; + u32_t max_cmp_val = 0U; + u32_t pwmscale = 0U; if (dev == NULL) { LOG_ERR("The device instance pointer was NULL\n"); @@ -124,7 +124,7 @@ static int pwm_sifive_pin_set(struct device *dev, } /* Channel 0 sets the period, we can't output PWM with it */ - if ((pwm == 0)) { + if ((pwm == 0U)) { LOG_ERR("PWM channel 0 cannot be configured\n"); return -ENOTSUP; } diff --git a/drivers/pwm/pwm_stm32.c b/drivers/pwm/pwm_stm32.c index f440efcf762..f0761fb3381 100644 --- a/drivers/pwm/pwm_stm32.c +++ b/drivers/pwm/pwm_stm32.c @@ -47,7 +47,7 @@ static u32_t __get_tim_clk(u32_t bus_clk, * Otherwise, they are set to twice (×2) the frequency of the * APB domain. */ - if (apb_psc == 1) { + if (apb_psc == 1U) { tim_clk = bus_clk; } else { tim_clk = 2 * bus_clk; @@ -76,7 +76,7 @@ static int pwm_stm32_pin_set(struct device *dev, u32_t pwm, u32_t channel; bool counter_32b; - if (period_cycles == 0 || pulse_cycles > period_cycles) { + if (period_cycles == 0U || pulse_cycles > period_cycles) { return -EINVAL; } diff --git a/drivers/sensor/adxl362/adxl362.c b/drivers/sensor/adxl362/adxl362.c index d9214a329ec..ef34192d6bf 100644 --- a/drivers/sensor/adxl362/adxl362.c +++ b/drivers/sensor/adxl362/adxl362.c @@ -130,7 +130,7 @@ static int adxl362_freq_to_odr_val(u16_t freq_int, u16_t freq_milli) size_t i; /* An ODR of 0 Hz is not allowed */ - if (freq_int == 0 && freq_milli == 0) { + if (freq_int == 0U && freq_milli == 0U) { return -EINVAL; } @@ -600,7 +600,7 @@ static int adxl362_init(struct device *dev) } data->adxl362_cs_ctrl.gpio_pin = config->cs_gpio; - data->adxl362_cs_ctrl.delay = 0; + data->adxl362_cs_ctrl.delay = 0U; data->spi_cfg.cs = &data->adxl362_cs_ctrl; #endif diff --git a/drivers/sensor/adxl372/adxl372.c b/drivers/sensor/adxl372/adxl372.c index d80220e3919..60ad0b4e17e 100644 --- a/drivers/sensor/adxl372/adxl372.c +++ b/drivers/sensor/adxl372/adxl372.c @@ -201,7 +201,7 @@ static int adxl372_set_activity_threshold_xyz(struct device *dev, if (ret) { return ret; } - axis_reg_h += 2; + axis_reg_h += 2U; } return 0; @@ -469,7 +469,7 @@ int adxl372_get_status(struct device *dev, } if (fifo_entries) { - length += 2; + length += 2U; } ret = adxl372_reg_read_multiple(dev, ADXL372_STATUS_1, buf, length); @@ -908,7 +908,7 @@ static int adxl372_init(struct device *dev) } data->adxl372_cs_ctrl.gpio_pin = cfg->cs_gpio; - data->adxl372_cs_ctrl.delay = 0; + data->adxl372_cs_ctrl.delay = 0U; data->spi_cfg.cs = &data->adxl372_cs_ctrl; #endif diff --git a/drivers/sensor/bma280/bma280_trigger.c b/drivers/sensor/bma280/bma280_trigger.c index 202b820d526..5450cb358e1 100644 --- a/drivers/sensor/bma280/bma280_trigger.c +++ b/drivers/sensor/bma280/bma280_trigger.c @@ -30,7 +30,7 @@ int bma280_attr_set(struct device *dev, if (attr == SENSOR_ATTR_SLOPE_TH) { /* slope_th = (val * 10^6 * 2^10) / BMA280_PMU_FULL_RAGE */ - slope_th = (u64_t)val->val1 * 1000000 + (u64_t)val->val2; + slope_th = (u64_t)val->val1 * 1000000U + (u64_t)val->val2; slope_th = (slope_th * (1 << 10)) / BMA280_PMU_FULL_RANGE; if (i2c_reg_write_byte(drv_data->i2c, BMA280_I2C_ADDRESS, BMA280_REG_SLOPE_TH, (u8_t)slope_th) diff --git a/drivers/sensor/bme280/bme280.c b/drivers/sensor/bme280/bme280.c index c54a5aeb433..856ce5aad61 100644 --- a/drivers/sensor/bme280/bme280.c +++ b/drivers/sensor/bme280/bme280.c @@ -213,9 +213,9 @@ static int bme280_channel_get(struct device *dev, * fractional. Output value of 24674867 represents * 24674867/256 = 96386.2 Pa = 963.862 hPa */ - val->val1 = (data->comp_press >> 8) / 1000; - val->val2 = (data->comp_press >> 8) % 1000 * 1000 + - (((data->comp_press & 0xff) * 1000) >> 8); + val->val1 = (data->comp_press >> 8) / 1000U; + val->val2 = (data->comp_press >> 8) % 1000 * 1000U + + (((data->comp_press & 0xff) * 1000U) >> 8); break; case SENSOR_CHAN_HUMIDITY: /* @@ -224,7 +224,7 @@ static int bme280_channel_get(struct device *dev, * 47445/1024 = 46.333 %RH */ val->val1 = (data->comp_humidity >> 10); - val->val2 = (((data->comp_humidity & 0x3ff) * 1000 * 1000) >> 10); + val->val2 = (((data->comp_humidity & 0x3ff) * 1000U * 1000U) >> 10); break; default: return -EINVAL; diff --git a/drivers/sensor/bmg160/bmg160_trigger.c b/drivers/sensor/bmg160/bmg160_trigger.c index 2554c0aa4cb..ac8f96a6dfd 100644 --- a/drivers/sensor/bmg160/bmg160_trigger.c +++ b/drivers/sensor/bmg160/bmg160_trigger.c @@ -83,10 +83,10 @@ int bmg160_slope_config(struct device *dev, enum sensor_attribute attr, any_th_dps = sensor_rad_to_degrees(val); range_dps = BMG160_SCALE_TO_RANGE(bmg160->scale); - any_th_reg_val = any_th_dps * 2000 / range_dps; + any_th_reg_val = any_th_dps * 2000U / range_dps; /* the maximum slope depends on selected range */ - if (any_th_dps > range_dps / 16) { + if (any_th_dps > range_dps / 16U) { return -ENOTSUP; } diff --git a/drivers/sensor/bmi160/bmi160.c b/drivers/sensor/bmi160/bmi160.c index 91ccf41aa91..cefa52b9ff8 100644 --- a/drivers/sensor/bmi160/bmi160.c +++ b/drivers/sensor/bmi160/bmi160.c @@ -176,7 +176,7 @@ static int bmi160_freq_to_odr_val(u16_t freq_int, u16_t freq_milli) size_t i; /* An ODR of 0 Hz is not allowed */ - if (freq_int == 0 && freq_milli == 0) { + if (freq_int == 0U && freq_milli == 0U) { return -EINVAL; } @@ -633,7 +633,7 @@ static int bmi160_sample_fetch(struct device *dev, enum sensor_channel chan) bmi160->sample.raw[0] = 0U; - while ((bmi160->sample.raw[0] & BMI160_DATA_READY_BIT_MASK) == 0) { + while ((bmi160->sample.raw[0] & BMI160_DATA_READY_BIT_MASK) == 0U) { if (bmi160_transceive(dev, BMI160_REG_STATUS | (1 << 7), false, bmi160->sample.raw, 1) < 0) { return -EIO; @@ -733,7 +733,7 @@ static int bmi160_temp_channel_get(struct device *dev, struct sensor_value *val) s32_t temp_micro = 0; struct bmi160_device_data *bmi160 = dev->driver_data; - if (bmi160->pmu_sts.raw == 0) { + if (bmi160->pmu_sts.raw == 0U) { return -EINVAL; } diff --git a/drivers/sensor/ccs811/ccs811.c b/drivers/sensor/ccs811/ccs811.c index f1fa254f49d..b845e087705 100644 --- a/drivers/sensor/ccs811/ccs811.c +++ b/drivers/sensor/ccs811/ccs811.c @@ -85,7 +85,7 @@ static int ccs811_channel_get(struct device *dev, */ uval = (drv_data->resistance & CCS811_VOLTAGE_MASK) * CCS811_VOLTAGE_SCALE; - val->val1 = uval / 1000000; + val->val1 = uval / 1000000U; val->val2 = uval % 1000000; break; @@ -95,7 +95,7 @@ static int ccs811_channel_get(struct device *dev, * significant 6 bits in microAmps */ uval = drv_data->resistance >> 10; - val->val1 = uval / 1000000; + val->val1 = uval / 1000000U; val->val2 = uval % 1000000; break; diff --git a/drivers/sensor/dht/dht.c b/drivers/sensor/dht/dht.c index d5ce37e3e66..9099a20b908 100644 --- a/drivers/sensor/dht/dht.c +++ b/drivers/sensor/dht/dht.c @@ -138,7 +138,7 @@ static int dht_sample_fetch(struct device *dev, enum sensor_channel chan) buf[j] = buf[j] << 1; } - if (i % 8 == 7) { + if (i % 8 == 7U) { j++; } } diff --git a/drivers/sensor/fxas21002/fxas21002.c b/drivers/sensor/fxas21002/fxas21002.c index 2d1a97afbd8..e9e39d2144f 100644 --- a/drivers/sensor/fxas21002/fxas21002.c +++ b/drivers/sensor/fxas21002/fxas21002.c @@ -175,9 +175,9 @@ u32_t fxas21002_get_transition_time(enum fxas21002_power start, transition_time = sample_period[dr]; if (start == FXAS21002_POWER_READY) { - transition_time += 5000; + transition_time += 5000U; } else { - transition_time += 60000; + transition_time += 60000U; } return transition_time; diff --git a/drivers/sensor/fxas21002/fxas21002_trigger.c b/drivers/sensor/fxas21002/fxas21002_trigger.c index 209a4cd8c90..83ac89a2c3e 100644 --- a/drivers/sensor/fxas21002/fxas21002_trigger.c +++ b/drivers/sensor/fxas21002/fxas21002_trigger.c @@ -19,7 +19,7 @@ static void fxas21002_gpio_callback(struct device *dev, struct fxas21002_data *data = CONTAINER_OF(cb, struct fxas21002_data, gpio_cb); - if ((pin_mask & BIT(data->gpio_pin)) == 0) { + if ((pin_mask & BIT(data->gpio_pin)) == 0U) { return; } diff --git a/drivers/sensor/fxos8700/fxos8700_trigger.c b/drivers/sensor/fxos8700/fxos8700_trigger.c index 20fddbc6e69..467a6aaf43f 100644 --- a/drivers/sensor/fxos8700/fxos8700_trigger.c +++ b/drivers/sensor/fxos8700/fxos8700_trigger.c @@ -18,7 +18,7 @@ static void fxos8700_gpio_callback(struct device *dev, struct fxos8700_data *data = CONTAINER_OF(cb, struct fxos8700_data, gpio_cb); - if ((pin_mask & BIT(data->gpio_pin)) == 0) { + if ((pin_mask & BIT(data->gpio_pin)) == 0U) { return; } diff --git a/drivers/sensor/hp206c/hp206c.c b/drivers/sensor/hp206c/hp206c.c index f4f8f76ab4e..43967af9cb0 100644 --- a/drivers/sensor/hp206c/hp206c.c +++ b/drivers/sensor/hp206c/hp206c.c @@ -114,7 +114,7 @@ static int hp206c_osr_set(struct device *dev, u16_t osr) ; } - if (i == 6) { + if (i == 6U) { return -ENOTSUP; } diff --git a/drivers/sensor/isl29035/isl29035.c b/drivers/sensor/isl29035/isl29035.c index 80402a219cd..e383ef10538 100644 --- a/drivers/sensor/isl29035/isl29035.c +++ b/drivers/sensor/isl29035/isl29035.c @@ -51,7 +51,7 @@ static int isl29035_channel_get(struct device *dev, /* val = sample_val * lux_range / (2 ^ adc_data_bits) */ tmp = (u64_t)drv_data->data_sample * ISL29035_LUX_RANGE; val->val1 = tmp >> ISL29035_ADC_DATA_BITS; - tmp = (tmp & ISL29035_ADC_DATA_MASK) * 1000000; + tmp = (tmp & ISL29035_ADC_DATA_MASK) * 1000000U; val->val2 = tmp >> ISL29035_ADC_DATA_BITS; #elif CONFIG_ISL29035_MODE_IR ARG_UNUSED(tmp); diff --git a/drivers/sensor/isl29035/isl29035_trigger.c b/drivers/sensor/isl29035/isl29035_trigger.c index 63363e4fd7f..dc4e248fabc 100644 --- a/drivers/sensor/isl29035/isl29035_trigger.c +++ b/drivers/sensor/isl29035/isl29035_trigger.c @@ -24,7 +24,7 @@ static u16_t isl29035_lux_processed_to_raw(struct sensor_value const *val) /* raw_val = val * (2 ^ adc_data_bits) / lux_range */ raw_val = (((u64_t)val->val1) << ISL29035_ADC_DATA_BITS) + - (((u64_t)val->val2) << ISL29035_ADC_DATA_BITS) / 1000000; + (((u64_t)val->val2) << ISL29035_ADC_DATA_BITS) / 1000000U; return raw_val / ISL29035_LUX_RANGE; } diff --git a/drivers/sensor/lis2dh/lis2dh.c b/drivers/sensor/lis2dh/lis2dh.c index 13ccfe501b3..1ed8e9d60e3 100644 --- a/drivers/sensor/lis2dh/lis2dh.c +++ b/drivers/sensor/lis2dh/lis2dh.c @@ -172,7 +172,7 @@ static int lis2dh_freq_to_odr_val(u16_t freq) size_t i; /* An ODR of 0 Hz is not allowed */ - if (freq == 0) { + if (freq == 0U) { return -EINVAL; } @@ -202,7 +202,7 @@ static int lis2dh_acc_odr_set(struct device *dev, u16_t freq) } /* some odr values cannot be set in certain power modes */ - if ((value & LIS2DH_LP_EN_BIT_MASK) == 0 && odr == LIS2DH_ODR_8) { + if ((value & LIS2DH_LP_EN_BIT_MASK) == 0U && odr == LIS2DH_ODR_8) { return -ENOTSUP; } diff --git a/drivers/sensor/lis2ds12/lis2ds12_spi.c b/drivers/sensor/lis2ds12/lis2ds12_spi.c index 099c85c0e3d..1a2c398e6d0 100644 --- a/drivers/sensor/lis2ds12/lis2ds12_spi.c +++ b/drivers/sensor/lis2ds12/lis2ds12_spi.c @@ -166,7 +166,7 @@ int lis2ds12_spi_init(struct device *dev) } lis2ds12_cs_ctrl.gpio_pin = DT_ST_LIS2DS12_0_CS_GPIO_PIN; - lis2ds12_cs_ctrl.delay = 0; + lis2ds12_cs_ctrl.delay = 0U; lis2ds12_spi_conf.cs = &lis2ds12_cs_ctrl; diff --git a/drivers/sensor/lis2dw12/lis2dw12.c b/drivers/sensor/lis2dw12/lis2dw12.c index ab16ffd8d22..38c2bd48ed6 100644 --- a/drivers/sensor/lis2dw12/lis2dw12.c +++ b/drivers/sensor/lis2dw12/lis2dw12.c @@ -35,7 +35,7 @@ static int lis2dw12_set_range(struct device *dev, u16_t range) int err; struct lis2dw12_data *lis2dw12 = dev->driver_data; const struct lis2dw12_device_config *cfg = dev->config->config_info; - u8_t shift_gain = 0; + u8_t shift_gain = 0U; err = lis2dw12->hw_tf->update_reg(lis2dw12, LIS2DW12_CTRL6_ADDR, LIS2DW12_FS_MASK, @@ -65,7 +65,7 @@ static int lis2dw12_set_odr(struct device *dev, u16_t odr) struct lis2dw12_data *lis2dw12 = dev->driver_data; /* check if power off */ - if (odr == 0) { + if (odr == 0U) { return lis2dw12->hw_tf->update_reg(lis2dw12, LIS2DW12_CTRL1_ADDR, LIS2DW12_ODR_MASK, @@ -105,16 +105,16 @@ static inline void lis2dw12_channel_get_acc(struct device *dev, switch (chan) { case SENSOR_CHAN_ACCEL_X: - ofs_start = ofs_stop = 0; + ofs_start = ofs_stop = 0U; break; case SENSOR_CHAN_ACCEL_Y: - ofs_start = ofs_stop = 1; + ofs_start = ofs_stop = 1U; break; case SENSOR_CHAN_ACCEL_Z: - ofs_start = ofs_stop = 2; + ofs_start = ofs_stop = 2U; break; default: - ofs_start = 0; ofs_stop = 2; + ofs_start = 0U; ofs_stop = 2U; break; } diff --git a/drivers/sensor/lis2dw12/lis2dw12_spi.c b/drivers/sensor/lis2dw12/lis2dw12_spi.c index b75ad36cbcf..9d1731985f9 100644 --- a/drivers/sensor/lis2dw12/lis2dw12_spi.c +++ b/drivers/sensor/lis2dw12/lis2dw12_spi.c @@ -161,7 +161,7 @@ int lis2dw12_spi_init(struct device *dev) } data->cs_ctrl.gpio_pin = DT_ST_LIS2DW12_0_CS_GPIO_PIN; - data->cs_ctrl.delay = 0; + data->cs_ctrl.delay = 0U; lis2dw12_spi_conf.cs = &data->cs_ctrl; diff --git a/drivers/sensor/lis2dw12/lis2dw12_trigger.c b/drivers/sensor/lis2dw12/lis2dw12_trigger.c index 1bd8ac9166d..08813ecbc83 100644 --- a/drivers/sensor/lis2dw12/lis2dw12_trigger.c +++ b/drivers/sensor/lis2dw12/lis2dw12_trigger.c @@ -27,7 +27,7 @@ static int lis2dw12_enable_int(struct device *dev, int enable) struct lis2dw12_data *lis2dw12 = dev->driver_data; /* set interrupt */ - if (cfg->int_pin == 1) + if (cfg->int_pin == 1U) return lis2dw12->hw_tf->update_reg(lis2dw12, LIS2DW12_CTRL4_ADDR, LIS2DW12_INT1_DRDY, diff --git a/drivers/sensor/lis2mdl/lis2mdl.c b/drivers/sensor/lis2mdl/lis2mdl.c index 8ee9fb60033..1bb0dce62fc 100644 --- a/drivers/sensor/lis2mdl/lis2mdl.c +++ b/drivers/sensor/lis2mdl/lis2mdl.c @@ -62,7 +62,7 @@ static int lis2mdl_set_odr(struct device *dev, u16_t odr) struct lis2mdl_data *lis2mdl = dev->driver_data; /* check if power off */ - if (odr == 0) { + if (odr == 0U) { /* power off mag */ return i2c_reg_update_byte(lis2mdl->i2c, lis2mdl->i2c_addr, diff --git a/drivers/sensor/lsm6dsl/lsm6dsl_shub.c b/drivers/sensor/lsm6dsl/lsm6dsl_shub.c index 6368aba4bc2..6906a81cd16 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl_shub.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl_shub.c @@ -150,7 +150,7 @@ static inline void lsm6dsl_shub_wait_completed(struct lsm6dsl_data *data) { u16_t freq; - freq = (data->accel_freq == 0) ? 26 : data->accel_freq; + freq = (data->accel_freq == 0U) ? 26 : data->accel_freq; k_sleep((2000U / freq) + 1); } @@ -387,7 +387,7 @@ int lsm6dsl_shub_init_external_chip(struct device *dev) for (i = 0U; i < ARRAY_SIZE(lsm6dsl_shub_sens_list[0].i2c_addr); i++) { slv_i2c_addr = lsm6dsl_shub_sens_list[0].i2c_addr[i]; - if (slv_i2c_addr == 0) { + if (slv_i2c_addr == 0U) { continue; } diff --git a/drivers/sensor/lsm6dsl/lsm6dsl_spi.c b/drivers/sensor/lsm6dsl/lsm6dsl_spi.c index 1d18184688d..da9be822c8c 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl_spi.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl_spi.c @@ -157,7 +157,7 @@ int lsm6dsl_spi_init(struct device *dev) } lsm6dsl_cs_ctrl.gpio_pin = DT_ST_LSM6DSL_0_CS_GPIO_PIN; - lsm6dsl_cs_ctrl.delay = 0; + lsm6dsl_cs_ctrl.delay = 0U; lsm6dsl_spi_conf.cs = &lsm6dsl_cs_ctrl; diff --git a/drivers/sensor/max44009/max44009.c b/drivers/sensor/max44009/max44009.c index c174ee837d7..aaab4bf6a7b 100644 --- a/drivers/sensor/max44009/max44009.c +++ b/drivers/sensor/max44009/max44009.c @@ -156,8 +156,8 @@ static int max44009_channel_get(struct device *dev, enum sensor_channel chan, uval = uval << (drv_data->sample >> MAX44009_SAMPLE_EXPONENT_SHIFT); /* lux is the integer of sample output multiplied by 0.045. */ - val->val1 = (uval * 45) / 1000; - val->val2 = ((uval * 45) % 1000) * 1000; + val->val1 = (uval * 45U) / 1000; + val->val2 = ((uval * 45U) % 1000) * 1000U; return 0; } diff --git a/drivers/sensor/mcp9808/mcp9808.c b/drivers/sensor/mcp9808/mcp9808.c index 7f31a25ea12..309753a0c3a 100644 --- a/drivers/sensor/mcp9808/mcp9808.c +++ b/drivers/sensor/mcp9808/mcp9808.c @@ -64,7 +64,7 @@ static int mcp9808_channel_get(struct device *dev, val->val1 = (data->reg_val & MCP9808_TEMP_INT_MASK) >> MCP9808_TEMP_INT_SHIFT; - val->val2 = (data->reg_val & MCP9808_TEMP_FRAC_MASK) * 62500; + val->val2 = (data->reg_val & MCP9808_TEMP_FRAC_MASK) * 62500U; if (data->reg_val & MCP9808_SIGN_BIT) { val->val1 -= 256; diff --git a/drivers/sensor/mpu6050/mpu6050.c b/drivers/sensor/mpu6050/mpu6050.c index 5795de7c437..bf319642398 100644 --- a/drivers/sensor/mpu6050/mpu6050.c +++ b/drivers/sensor/mpu6050/mpu6050.c @@ -177,7 +177,7 @@ int mpu6050_init(struct device *dev) } } - if (i == 4) { + if (i == 4U) { LOG_ERR("Invalid value for accel full-scale range."); return -EINVAL; } @@ -198,7 +198,7 @@ int mpu6050_init(struct device *dev) } } - if (i == 4) { + if (i == 4U) { LOG_ERR("Invalid value for gyro full-scale range."); return -EINVAL; } diff --git a/drivers/sensor/sht3xd/sht3xd.c b/drivers/sensor/sht3xd/sht3xd.c index 2c917cdcc99..e12103b54c7 100644 --- a/drivers/sensor/sht3xd/sht3xd.c +++ b/drivers/sensor/sht3xd/sht3xd.c @@ -135,7 +135,7 @@ static int sht3xd_channel_get(struct device *dev, u32_t tmp2 = 100 * (u32_t)data->rh_sample; val->val1 = tmp2 / 0xFFFF; /* x * 100000 / 65536 == x * 15625 / 1024 */ - val->val2 = (tmp2 % 0xFFFF) * 15625 / 1024; + val->val2 = (tmp2 % 0xFFFF) * 15625U / 1024; } else { return -ENOTSUP; } diff --git a/drivers/sensor/sht3xd/sht3xd_trigger.c b/drivers/sensor/sht3xd/sht3xd_trigger.c index 08f79059347..5d574510eb7 100644 --- a/drivers/sensor/sht3xd/sht3xd_trigger.c +++ b/drivers/sensor/sht3xd/sht3xd_trigger.c @@ -20,7 +20,7 @@ static u16_t sht3xd_temp_processed_to_raw(const struct sensor_value *val) u64_t uval; /* ret = (val + 45) * (2^16 - 1) / 175 */ - uval = (u64_t)(val->val1 + 45) * 1000000 + val->val2; + uval = (u64_t)(val->val1 + 45) * 1000000U + val->val2; return ((uval * 0xFFFF) / 175) / 1000000; } @@ -29,7 +29,7 @@ static int sht3xd_rh_processed_to_raw(const struct sensor_value *val) u64_t uval; /* ret = val * (2^16 -1) / 100 */ - uval = (u64_t)val->val1 * 1000000 + val->val2; + uval = (u64_t)val->val1 * 1000000U + val->val2; return ((uval * 0xFFFF) / 100) / 1000000; } diff --git a/drivers/sensor/th02/th02.c b/drivers/sensor/th02/th02.c index 158c34e03ea..6d95ca63e25 100644 --- a/drivers/sensor/th02/th02.c +++ b/drivers/sensor/th02/th02.c @@ -109,11 +109,11 @@ static int th02_channel_get(struct device *dev, enum sensor_channel chan, if (chan == SENSOR_CHAN_AMBIENT_TEMP) { /* val = sample / 32 - 50 */ - val->val1 = drv_data->t_sample / 32 - 50; + val->val1 = drv_data->t_sample / 32U - 50; val->val2 = (drv_data->t_sample % 32) * (1000000 / 32); } else { /* val = sample / 16 -24 */ - val->val1 = drv_data->rh_sample / 16 - 24; + val->val1 = drv_data->rh_sample / 16U - 24; val->val2 = (drv_data->rh_sample % 16) * (1000000 / 16); } diff --git a/drivers/serial/leuart_gecko.c b/drivers/serial/leuart_gecko.c index 855aab69c3b..a3751b696fe 100644 --- a/drivers/serial/leuart_gecko.c +++ b/drivers/serial/leuart_gecko.c @@ -142,7 +142,7 @@ static int leuart_gecko_irq_tx_complete(struct device *dev) LEUART_TypeDef *base = DEV_BASE(dev); u32_t flags = LEUART_IntGet(base); - return (flags & LEUART_IF_TXC) != 0; + return (flags & LEUART_IF_TXC) != 0U; } static int leuart_gecko_irq_tx_ready(struct device *dev) @@ -150,7 +150,7 @@ static int leuart_gecko_irq_tx_ready(struct device *dev) LEUART_TypeDef *base = DEV_BASE(dev); u32_t flags = LEUART_IntGet(base); - return (flags & LEUART_IF_TXBL) != 0; + return (flags & LEUART_IF_TXBL) != 0U; } static void leuart_gecko_irq_rx_enable(struct device *dev) @@ -174,7 +174,7 @@ static int leuart_gecko_irq_rx_full(struct device *dev) LEUART_TypeDef *base = DEV_BASE(dev); u32_t flags = LEUART_IntGet(base); - return (flags & LEUART_IF_RXDATAV) != 0; + return (flags & LEUART_IF_RXDATAV) != 0U; } static int leuart_gecko_irq_rx_ready(struct device *dev) diff --git a/drivers/serial/uart_cmsdk_apb.c b/drivers/serial/uart_cmsdk_apb.c index 83ec5bd60c7..c5399f6af32 100644 --- a/drivers/serial/uart_cmsdk_apb.c +++ b/drivers/serial/uart_cmsdk_apb.c @@ -103,7 +103,7 @@ static void baudrate_set(struct device *dev) * unchanged. It can be useful in case that Zephyr it is run via * a bootloader that brings up the serial and sets the baudrate. */ - if ((dev_data->baud_rate != 0) && (dev_cfg->sys_clk_freq != 0)) { + if ((dev_data->baud_rate != 0U) && (dev_cfg->sys_clk_freq != 0U)) { /* calculate baud rate divisor */ uart->bauddiv = (dev_cfg->sys_clk_freq / dev_data->baud_rate); } diff --git a/drivers/serial/uart_gecko.c b/drivers/serial/uart_gecko.c index fb096a8baef..12e1f30b91b 100644 --- a/drivers/serial/uart_gecko.c +++ b/drivers/serial/uart_gecko.c @@ -134,7 +134,7 @@ static int uart_gecko_irq_tx_complete(struct device *dev) USART_IntClear(config->base, USART_IF_TXC); - return (flags & USART_IF_TXC) != 0; + return (flags & USART_IF_TXC) != 0U; } static int uart_gecko_irq_tx_ready(struct device *dev) @@ -142,7 +142,7 @@ static int uart_gecko_irq_tx_ready(struct device *dev) const struct uart_gecko_config *config = dev->config->config_info; u32_t flags = USART_IntGet(config->base); - return (flags & USART_IF_TXBL) != 0; + return (flags & USART_IF_TXBL) != 0U; } static void uart_gecko_irq_rx_enable(struct device *dev) @@ -166,7 +166,7 @@ static int uart_gecko_irq_rx_full(struct device *dev) const struct uart_gecko_config *config = dev->config->config_info; u32_t flags = USART_IntGet(config->base); - return (flags & USART_IF_RXDATAV) != 0; + return (flags & USART_IF_RXDATAV) != 0U; } static int uart_gecko_irq_rx_ready(struct device *dev) diff --git a/drivers/serial/uart_mcux.c b/drivers/serial/uart_mcux.c index 86137ec5ddc..cfda3ef3a05 100644 --- a/drivers/serial/uart_mcux.c +++ b/drivers/serial/uart_mcux.c @@ -130,7 +130,7 @@ static int uart_mcux_irq_tx_complete(struct device *dev) const struct uart_mcux_config *config = dev->config->config_info; u32_t flags = UART_GetStatusFlags(config->base); - return (flags & kUART_TxDataRegEmptyFlag) != 0; + return (flags & kUART_TxDataRegEmptyFlag) != 0U; } static int uart_mcux_irq_tx_ready(struct device *dev) @@ -163,7 +163,7 @@ static int uart_mcux_irq_rx_full(struct device *dev) const struct uart_mcux_config *config = dev->config->config_info; u32_t flags = UART_GetStatusFlags(config->base); - return (flags & kUART_RxDataRegFullFlag) != 0; + return (flags & kUART_RxDataRegFullFlag) != 0U; } static int uart_mcux_irq_rx_ready(struct device *dev) diff --git a/drivers/serial/uart_mcux_lpsci.c b/drivers/serial/uart_mcux_lpsci.c index 9148e6bc0d8..2481fc66898 100644 --- a/drivers/serial/uart_mcux_lpsci.c +++ b/drivers/serial/uart_mcux_lpsci.c @@ -132,7 +132,7 @@ static int mcux_lpsci_irq_tx_complete(struct device *dev) const struct mcux_lpsci_config *config = dev->config->config_info; u32_t flags = LPSCI_GetStatusFlags(config->base); - return (flags & kLPSCI_TxDataRegEmptyFlag) != 0; + return (flags & kLPSCI_TxDataRegEmptyFlag) != 0U; } static int mcux_lpsci_irq_tx_ready(struct device *dev) @@ -165,7 +165,7 @@ static int mcux_lpsci_irq_rx_full(struct device *dev) const struct mcux_lpsci_config *config = dev->config->config_info; u32_t flags = LPSCI_GetStatusFlags(config->base); - return (flags & kLPSCI_RxDataRegFullFlag) != 0; + return (flags & kLPSCI_RxDataRegFullFlag) != 0U; } static int mcux_lpsci_irq_rx_ready(struct device *dev) diff --git a/drivers/serial/uart_mcux_lpuart.c b/drivers/serial/uart_mcux_lpuart.c index f310606edf5..c4bb661d324 100644 --- a/drivers/serial/uart_mcux_lpuart.c +++ b/drivers/serial/uart_mcux_lpuart.c @@ -132,7 +132,7 @@ static int mcux_lpuart_irq_tx_complete(struct device *dev) const struct mcux_lpuart_config *config = dev->config->config_info; u32_t flags = LPUART_GetStatusFlags(config->base); - return (flags & kLPUART_TxDataRegEmptyFlag) != 0; + return (flags & kLPUART_TxDataRegEmptyFlag) != 0U; } static int mcux_lpuart_irq_tx_ready(struct device *dev) @@ -165,7 +165,7 @@ static int mcux_lpuart_irq_rx_full(struct device *dev) const struct mcux_lpuart_config *config = dev->config->config_info; u32_t flags = LPUART_GetStatusFlags(config->base); - return (flags & kLPUART_RxDataRegFullFlag) != 0; + return (flags & kLPUART_RxDataRegFullFlag) != 0U; } static int mcux_lpuart_irq_rx_ready(struct device *dev) diff --git a/drivers/serial/uart_ns16550.c b/drivers/serial/uart_ns16550.c index 62e56500557..224e13177f0 100644 --- a/drivers/serial/uart_ns16550.c +++ b/drivers/serial/uart_ns16550.c @@ -286,7 +286,7 @@ static void set_baud_rate(struct device *dev, u32_t baud_rate) u32_t divisor; /* baud rate divisor */ u8_t lcr_cache; - if ((baud_rate != 0) && (dev_cfg->sys_clk_freq != 0)) { + if ((baud_rate != 0U) && (dev_cfg->sys_clk_freq != 0U)) { /* * calculate baud rate divisor. a variant of * (u32_t)(dev_cfg->sys_clk_freq / (16.0 * baud_rate) + 0.5) diff --git a/drivers/serial/uart_pl011.c b/drivers/serial/uart_pl011.c index 087379115fd..a4539efe3c0 100644 --- a/drivers/serial/uart_pl011.c +++ b/drivers/serial/uart_pl011.c @@ -201,7 +201,7 @@ static bool pl011_is_readable(struct device *dev) { if ((PL011_REGS(dev)->cr & PL011_CR_UARTEN) && (PL011_REGS(dev)->cr & PL011_CR_RXE) && - ((PL011_REGS(dev)->fr & PL011_FR_RXFE) == 0)) { + ((PL011_REGS(dev)->fr & PL011_FR_RXFE) == 0U)) { return true; } @@ -236,7 +236,7 @@ static void pl011_poll_out(struct device *dev, static int pl011_fifo_fill(struct device *dev, const u8_t *tx_data, int len) { - u8_t num_tx = 0; + u8_t num_tx = 0U; while (!(PL011_REGS(dev)->fr & PL011_FR_TXFF) && (len - num_tx > 0)) { @@ -248,7 +248,7 @@ static int pl011_fifo_fill(struct device *dev, static int pl011_fifo_read(struct device *dev, u8_t *rx_data, const int len) { - u8_t num_rx = 0; + u8_t num_rx = 0U; while ((len - num_rx > 0) && !(PL011_REGS(dev)->fr & PL011_FR_RXFE)) { @@ -377,10 +377,10 @@ static int pl011_init(struct device *dev) pl011_enable_fifo(dev); /* initialize all IRQs as masked */ - PL011_REGS(dev)->imsc = 0; + PL011_REGS(dev)->imsc = 0U; PL011_REGS(dev)->icr = PL011_IMSC_MASK_ALL; - PL011_REGS(dev)->dmacr = 0; + PL011_REGS(dev)->dmacr = 0U; __ISB(); PL011_REGS(dev)->cr &= ~(BIT(14) | BIT(15) | BIT(1)); PL011_REGS(dev)->cr |= PL011_CR_RXE | PL011_CR_TXE; diff --git a/drivers/serial/uart_rv32m1_lpuart.c b/drivers/serial/uart_rv32m1_lpuart.c index 195cd5059b2..921dd4c9879 100644 --- a/drivers/serial/uart_rv32m1_lpuart.c +++ b/drivers/serial/uart_rv32m1_lpuart.c @@ -87,7 +87,7 @@ static int rv32m1_lpuart_fifo_fill(struct device *dev, const u8_t *tx_data, int len) { const struct rv32m1_lpuart_config *config = dev->config->config_info; - u8_t num_tx = 0; + u8_t num_tx = 0U; while ((len - num_tx > 0) && (LPUART_GetStatusFlags(config->base) @@ -103,7 +103,7 @@ static int rv32m1_lpuart_fifo_read(struct device *dev, u8_t *rx_data, const int len) { const struct rv32m1_lpuart_config *config = dev->config->config_info; - u8_t num_rx = 0; + u8_t num_rx = 0U; while ((len - num_rx > 0) && (LPUART_GetStatusFlags(config->base) @@ -136,7 +136,7 @@ static int rv32m1_lpuart_irq_tx_complete(struct device *dev) const struct rv32m1_lpuart_config *config = dev->config->config_info; u32_t flags = LPUART_GetStatusFlags(config->base); - return (flags & kLPUART_TxDataRegEmptyFlag) != 0; + return (flags & kLPUART_TxDataRegEmptyFlag) != 0U; } static int rv32m1_lpuart_irq_tx_ready(struct device *dev) @@ -169,7 +169,7 @@ static int rv32m1_lpuart_irq_rx_full(struct device *dev) const struct rv32m1_lpuart_config *config = dev->config->config_info; u32_t flags = LPUART_GetStatusFlags(config->base); - return (flags & kLPUART_RxDataRegFullFlag) != 0; + return (flags & kLPUART_RxDataRegFullFlag) != 0U; } static int rv32m1_lpuart_irq_rx_ready(struct device *dev) diff --git a/drivers/serial/uart_sam.c b/drivers/serial/uart_sam.c index 9bc74f1569c..768c27f717d 100644 --- a/drivers/serial/uart_sam.c +++ b/drivers/serial/uart_sam.c @@ -192,10 +192,10 @@ static int baudrate_set(Uart *const uart, u32_t baudrate, __ASSERT(baudrate, "baud rate has to be bigger than 0"); - __ASSERT(mck_freq_hz/16 >= baudrate, + __ASSERT(mck_freq_hz/16U >= baudrate, "MCK frequency is too small to set required baud rate"); - divisor = mck_freq_hz / 16 / baudrate; + divisor = mck_freq_hz / 16U / baudrate; if (divisor > 0xFFFF) { return -EINVAL; diff --git a/drivers/serial/uart_stellaris.c b/drivers/serial/uart_stellaris.c index 10eeaaab0db..3f77f980317 100644 --- a/drivers/serial/uart_stellaris.c +++ b/drivers/serial/uart_stellaris.c @@ -172,7 +172,7 @@ static void baudrate_set(struct device *dev, * floating part of baud rate (LM3S6965 p.433), equivalent to * [float part of (SYSCLK / div)] * 64 + 0.5 */ - brdf = ((((rem * 64) << 1) / div) + 1) >> 1; + brdf = ((((rem * 64U) << 1) / div) + 1) >> 1; /* integer part of baud rate (LM3S6965 p.433) */ brdi = sys_clk_freq_hz / div; @@ -351,7 +351,7 @@ static int uart_stellaris_fifo_fill(struct device *dev, const u8_t *tx_data, volatile struct _uart *uart = UART_STRUCT(dev); u8_t num_tx = 0U; - while ((len - num_tx > 0) && ((uart->fr & UARTFR_TXFF) == 0)) { + while ((len - num_tx > 0) && ((uart->fr & UARTFR_TXFF) == 0U)) { uart->dr = (u32_t)tx_data[num_tx++]; } @@ -373,7 +373,7 @@ static int uart_stellaris_fifo_read(struct device *dev, u8_t *rx_data, volatile struct _uart *uart = UART_STRUCT(dev); u8_t num_rx = 0U; - while ((size - num_rx > 0) && ((uart->fr & UARTFR_RXFE) == 0)) { + while ((size - num_rx > 0) && ((uart->fr & UARTFR_RXFE) == 0U)) { rx_data[num_rx++] = (u8_t)uart->dr; } diff --git a/drivers/serial/usart_sam.c b/drivers/serial/usart_sam.c index 32cb25f8710..4adcd18e53e 100644 --- a/drivers/serial/usart_sam.c +++ b/drivers/serial/usart_sam.c @@ -178,10 +178,10 @@ static int baudrate_set(Usart *const usart, u32_t baudrate, __ASSERT(baudrate, "baud rate has to be bigger than 0"); - __ASSERT(mck_freq_hz/16 >= baudrate, + __ASSERT(mck_freq_hz/16U >= baudrate, "MCK frequency is too small to set required baud rate"); - divisor = mck_freq_hz / 16 / baudrate; + divisor = mck_freq_hz / 16U / baudrate; if (divisor > 0xFFFF) { return -EINVAL; diff --git a/drivers/spi/spi_sam.c b/drivers/spi/spi_sam.c index 4eca75d2a7c..763b1f2c4f2 100644 --- a/drivers/spi/spi_sam.c +++ b/drivers/spi/spi_sam.c @@ -76,11 +76,11 @@ static int spi_sam_configure(struct device *dev, spi_mr |= (SPI_MR_MSTR | SPI_MR_MODFDIS); spi_mr |= SPI_MR_PCS(spi_slave_to_mr_pcs(config->slave)); - if ((config->operation & SPI_MODE_CPOL) != 0) { + if ((config->operation & SPI_MODE_CPOL) != 0U) { spi_csr |= SPI_CSR_CPOL; } - if ((config->operation & SPI_MODE_CPHA) == 0) { + if ((config->operation & SPI_MODE_CPHA) == 0U) { spi_csr |= SPI_CSR_NCPHA; } diff --git a/drivers/spi/spi_sam0.c b/drivers/spi/spi_sam0.c index 594234d1ff7..4e836e83108 100644 --- a/drivers/spi/spi_sam0.c +++ b/drivers/spi/spi_sam0.c @@ -63,21 +63,21 @@ static int spi_sam0_configure(struct device *dev, ctrla.bit.MODE = SERCOM_SPI_CTRLA_MODE_SPI_MASTER_Val; - if ((config->operation & SPI_TRANSFER_LSB) != 0) { + if ((config->operation & SPI_TRANSFER_LSB) != 0U) { ctrla.bit.DORD = 1; } - if ((config->operation & SPI_MODE_CPOL) != 0) { + if ((config->operation & SPI_MODE_CPOL) != 0U) { ctrla.bit.CPOL = 1; } - if ((config->operation & SPI_MODE_CPHA) != 0) { + if ((config->operation & SPI_MODE_CPHA) != 0U) { ctrla.bit.CPHA = 1; } ctrla.reg |= cfg->pads; - if ((config->operation & SPI_MODE_LOOP) != 0) { + if ((config->operation & SPI_MODE_LOOP) != 0U) { /* Put MISO and MOSI on the same pad */ ctrla.bit.DOPO = 0; ctrla.bit.DIPO = 0; @@ -94,7 +94,7 @@ static int spi_sam0_configure(struct device *dev, ctrlb.bit.CHSIZE = 0; /* Use the requested or next higest possible frequency */ - div = (SOC_ATMEL_SAM0_GCLK0_FREQ_HZ / config->frequency) / 2 - 1; + div = (SOC_ATMEL_SAM0_GCLK0_FREQ_HZ / config->frequency) / 2U - 1; div = MAX(0, MIN(UINT8_MAX, div)); /* Update the configuration only if it has changed */ diff --git a/drivers/timer/loapic_timer.c b/drivers/timer/loapic_timer.c index d0818fde784..6a5138244a7 100644 --- a/drivers/timer/loapic_timer.c +++ b/drivers/timer/loapic_timer.c @@ -387,7 +387,7 @@ u32_t _get_program_time(void) u32_t _get_remaining_program_time(void) { - if (programmed_full_ticks == 0) { + if (programmed_full_ticks == 0U) { return 0; } @@ -396,7 +396,7 @@ u32_t _get_remaining_program_time(void) u32_t _get_elapsed_program_time(void) { - if (programmed_full_ticks == 0) { + if (programmed_full_ticks == 0U) { return 0; } @@ -573,7 +573,7 @@ void z_clock_idle_exit(void) remaining_cycles = current_count_register_get(); - if ((remaining_cycles == 0) || + if ((remaining_cycles == 0U) || (remaining_cycles >= programmed_cycles)) { /* * The timer has expired. The handler _timer_int_handler() is diff --git a/drivers/timer/sam0_rtc_timer.c b/drivers/timer/sam0_rtc_timer.c index 0362b1f0dbf..6e131266210 100644 --- a/drivers/timer/sam0_rtc_timer.c +++ b/drivers/timer/sam0_rtc_timer.c @@ -164,7 +164,7 @@ int z_clock_driver_init(struct device *device) /* Reset module to hardware defaults. */ rtc_reset(); - rtc_last = 0; + rtc_last = 0U; /* Configure RTC with 32-bit mode, configured prescaler and MATCHCLR. */ u16_t ctrl = RTC_MODE0_CTRL_MODE(0) | RTC_MODE0_CTRL_PRESCALER(0); @@ -182,8 +182,8 @@ int z_clock_driver_init(struct device *device) rtc_sync(); RTC0->COMP[0].reg = CYCLES_PER_TICK; RTC0->INTENSET.reg = RTC_MODE0_INTENSET_OVF; - rtc_counter = 0; - rtc_timeout = 0; + rtc_counter = 0U; + rtc_timeout = 0U; #endif /* Enable RTC module. */ diff --git a/drivers/usb/device/usb_dc_dw.c b/drivers/usb/device/usb_dc_dw.c index 6918cac52fc..c4c8bf96c59 100644 --- a/drivers/usb/device/usb_dc_dw.c +++ b/drivers/usb/device/usb_dc_dw.c @@ -398,7 +398,7 @@ static int usb_dw_tx(u8_t ep, const u8_t *const data, key = irq_lock(); - avail_space *= 4; + avail_space *= 4U; if (!avail_space) { LOG_ERR("USB IN EP%d no space available, DTXFSTS %x", ep_idx, USB_DW->in_ep_reg[ep_idx].dtxfsts); @@ -416,7 +416,7 @@ static int usb_dw_tx(u8_t ep, const u8_t *const data, data_len = avail_space; } - if (data_len != 0) { + if (data_len != 0U) { /* Get max packet size and packet count for ep */ if (ep_idx == USB_DW_IN_EP_0) { max_pkt_cnt = @@ -478,7 +478,7 @@ static int usb_dw_tx(u8_t ep, const u8_t *const data, * to access a FIFO, the application must complete the transaction * before accessing the register." */ - for (i = 0U; i < data_len; i += 4) { + for (i = 0U; i < data_len; i += 4U) { u32_t val = data[i]; if (i + 1 < data_len) { @@ -1119,7 +1119,7 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len, bytes_to_copy); /* Data in the FIFOs is always stored per 32-bit words */ - for (i = 0U; i < (bytes_to_copy & ~0x3); i += 4) { + for (i = 0U; i < (bytes_to_copy & ~0x3); i += 4U) { *(u32_t *)(data + i) = USB_DW_EP_FIFO(ep_idx); } if (bytes_to_copy & 0x3) { diff --git a/drivers/usb/device/usb_dc_kinetis.c b/drivers/usb/device/usb_dc_kinetis.c index a87c833f154..8157433a3ad 100644 --- a/drivers/usb/device/usb_dc_kinetis.c +++ b/drivers/usb/device/usb_dc_kinetis.c @@ -332,8 +332,8 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg) (void)memset(&bdt[idx_even], 0, sizeof(struct buf_descriptor)); (void)memset(&bdt[idx_odd], 0, sizeof(struct buf_descriptor)); - if (k_mem_pool_alloc(&ep_buf_pool, block, cfg->ep_mps * 2, 10) == 0) { - (void)memset(block->data, 0, cfg->ep_mps * 2); + if (k_mem_pool_alloc(&ep_buf_pool, block, cfg->ep_mps * 2U, 10) == 0) { + (void)memset(block->data, 0, cfg->ep_mps * 2U); } else { LOG_ERR("Memory allocation time-out"); return -ENOMEM; @@ -442,7 +442,7 @@ int usb_dc_ep_clear_stall(const u8_t ep) } /* Resume TX token processing, see USBx_CTL field descriptions */ - if (ep == 0) { + if (ep == 0U) { USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK; } @@ -730,7 +730,7 @@ int usb_dc_ep_read_continue(u8_t ep) } /* Resume TX token processing, see USBx_CTL field descriptions */ - if (ep_idx == 0) { + if (ep_idx == 0U) { USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK; } diff --git a/drivers/usb/device/usb_dc_native_posix.c b/drivers/usb/device/usb_dc_native_posix.c index 7ebb386aa1b..452508291b7 100644 --- a/drivers/usb/device/usb_dc_native_posix.c +++ b/drivers/usb/device/usb_dc_native_posix.c @@ -119,7 +119,7 @@ int usb_dc_attach(void) thread_main, NULL, NULL, NULL, K_PRIO_COOP(2), 0, K_NO_WAIT); - usbip_ctrl.attached = 1; + usbip_ctrl.attached = 1U; return 0; } @@ -132,7 +132,7 @@ int usb_dc_detach(void) return 0; } - usbip_ctrl.attached = 0; + usbip_ctrl.attached = 0U; return 0; } @@ -284,9 +284,9 @@ int usb_dc_ep_enable(const u8_t ep) /* Enable Ep */ if (USBIP_EP_ADDR2DIR(ep) == USB_EP_DIR_OUT) { - usbip_ctrl.out_ep_ctrl[ep_idx].ep_ena = 1; + usbip_ctrl.out_ep_ctrl[ep_idx].ep_ena = 1U; } else { - usbip_ctrl.in_ep_ctrl[ep_idx].ep_ena = 1; + usbip_ctrl.in_ep_ctrl[ep_idx].ep_ena = 1U; } return 0; diff --git a/drivers/usb/device/usb_dc_native_posix_adapt.c b/drivers/usb/device/usb_dc_native_posix_adapt.c index 3cbe4c0ce82..144d8abe099 100644 --- a/drivers/usb/device/usb_dc_native_posix_adapt.c +++ b/drivers/usb/device/usb_dc_native_posix_adapt.c @@ -100,7 +100,7 @@ static int send_interfaces(const u8_t *descriptors, int connfd) iface.bInterfaceClass = desc->bInterfaceClass; iface.bInterfaceSubClass = desc->bInterfaceSubClass; iface.bInterfaceProtocol = desc->bInterfaceProtocol; - iface.padding = 0; + iface.padding = 0U; if (send(connfd, &iface, sizeof(iface), 0) != sizeof(iface)) { @@ -332,7 +332,7 @@ void usbip_start(void) LOG_DBG("Connection: %s", inet_ntoa(client_addr.sin_addr)); /* Set attached 0 */ - attached = 0; + attached = 0U; while (true) { struct usbip_header cmd; @@ -371,7 +371,7 @@ void usbip_start(void) break; case OP_REQ_IMPORT: if (!handle_import(desc, connfd)) { - attached = 1; + attached = 1U; } break; default: diff --git a/drivers/usb/device/usb_dc_nrfx.c b/drivers/usb/device/usb_dc_nrfx.c index fe653706d3c..1cc79a2ebcf 100644 --- a/drivers/usb/device/usb_dc_nrfx.c +++ b/drivers/usb/device/usb_dc_nrfx.c @@ -851,7 +851,7 @@ static inline void usbd_work_process_setup(struct nrf_usbd_ep_ctx *ep_ctx) ctx->ctrl_read_len -= usbd_setup->wLength; nrfx_usbd_setup_data_clear(); } else { - ctx->ctrl_read_len = 0; + ctx->ctrl_read_len = 0U; } } @@ -1002,7 +1002,7 @@ static void usbd_event_transfer_ctrl(nrfx_usbd_evt_t const *const p_event) ctx->ctrl_read_len -= ep_ctx->buf.len; nrfx_usbd_setup_data_clear(); } else { - ctx->ctrl_read_len = 0; + ctx->ctrl_read_len = 0U; } usbd_evt_put(ev); @@ -1441,7 +1441,7 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data *const ep_cfg) ep_ctx->cfg.type = ep_cfg->ep_type; ep_ctx->cfg.max_sz = ep_cfg->ep_mps; - if ((ep_cfg->ep_mps & (ep_cfg->ep_mps - 1)) != 0) { + if ((ep_cfg->ep_mps & (ep_cfg->ep_mps - 1)) != 0U) { LOG_ERR("EP max packet size must be a power of 2."); return -EINVAL; } diff --git a/drivers/usb/device/usb_dc_sam.c b/drivers/usb/device/usb_dc_sam.c index 80f22620216..0c87cef161f 100644 --- a/drivers/usb/device/usb_dc_sam.c +++ b/drivers/usb/device/usb_dc_sam.c @@ -101,7 +101,7 @@ static void usb_dc_ep_reset(u8_t ep_idx) /* Enable endpoint interrupts, depending of the type and direction */ static void usb_dc_ep_enable_interrupts(u8_t ep_idx) { - if (ep_idx == 0) { + if (ep_idx == 0U) { /* Control endpoint: enable SETUP and OUT */ USBHS->USBHS_DEVEPTIER[ep_idx] = USBHS_DEVEPTIER_RXSTPES; USBHS->USBHS_DEVEPTIER[ep_idx] = USBHS_DEVEPTIER_RXOUTES; @@ -162,7 +162,7 @@ static void usb_dc_ep0_isr(void) dev_data.ep_data[0].cb_in(USB_EP_DIR_IN, USB_DC_EP_DATA_IN); if (!(dev_ctrl & USBHS_DEVCTRL_ADDEN) && - (dev_ctrl & USBHS_DEVCTRL_UADD_Msk) != 0) { + (dev_ctrl & USBHS_DEVCTRL_UADD_Msk) != 0U) { /* Commit the pending address update. This * must be done after the ack to the host * completes else the ack will get dropped. @@ -390,7 +390,7 @@ int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg) return -1; } - if (ep_idx == 0) { + if (ep_idx == 0U) { if (cfg->ep_type != USB_DC_EP_CONTROL) { LOG_ERR("pre-selected as control endpoint"); return -1; @@ -701,7 +701,7 @@ int usb_dc_ep_write(u8_t ep, const u8_t *data, u32_t data_len, u32_t *ret_bytes) } __DSB(); - if (ep_idx == 0) { + if (ep_idx == 0U) { /* * Control endpoint: clear the interrupt flag to send the data, * and re-enable the interrupts to trigger an interrupt at the @@ -851,7 +851,7 @@ int usb_dc_ep_read_continue(u8_t ep) return -EINVAL; } - if (ep_idx == 0) { + if (ep_idx == 0U) { /* * Control endpoint: clear the interrupt flag to send the data. * It is easier to clear both SETUP and OUT flag than checking diff --git a/drivers/usb/device/usb_dc_sam0.c b/drivers/usb/device/usb_dc_sam0.c index 672d56d9c03..91691298f6e 100644 --- a/drivers/usb/device/usb_dc_sam0.c +++ b/drivers/usb/device/usb_dc_sam0.c @@ -55,21 +55,21 @@ static void usb_sam0_ep_isr(u8_t ep) endpoint->EPINTFLAG.reg = intflag; - if ((intflag & USB_DEVICE_EPINTFLAG_RXSTP) != 0) { + if ((intflag & USB_DEVICE_EPINTFLAG_RXSTP) != 0U) { /* Setup */ data->ep_cb[0][ep](ep, USB_DC_EP_SETUP); } - if ((intflag & USB_DEVICE_EPINTFLAG_TRCPT0) != 0) { + if ((intflag & USB_DEVICE_EPINTFLAG_TRCPT0) != 0U) { /* Out (to device) data received */ data->ep_cb[0][ep](ep, USB_DC_EP_DATA_OUT); } - if ((intflag & USB_DEVICE_EPINTFLAG_TRCPT1) != 0) { + if ((intflag & USB_DEVICE_EPINTFLAG_TRCPT1) != 0U) { /* In (to host) transmit complete */ data->ep_cb[1][ep](ep | USB_SAM0_IN_EP, USB_DC_EP_DATA_IN); - if (data->addr != 0) { + if (data->addr != 0U) { /* Commit the pending address update. This * must be done after the ack to the host * completes else the ack will get dropped. @@ -92,7 +92,7 @@ static void usb_sam0_isr(void) /* Acknowledge all interrupts */ regs->INTFLAG.reg = intflag; - if ((intflag & USB_DEVICE_INTFLAG_EORST) != 0) { + if ((intflag & USB_DEVICE_INTFLAG_EORST) != 0U) { UsbDeviceEndpoint *endpoint = ®s->DeviceEndpoint[0]; /* The device clears some of the configuration of EP0 @@ -106,9 +106,9 @@ static void usb_sam0_isr(void) } /* Dispatch the endpoint interrupts */ - for (ep = 0U; epint != 0; epint >>= 1) { + for (ep = 0U; epint != 0U; epint >>= 1) { /* Scan bit-by-bit as the Cortex-M0 doesn't have ffs */ - if ((epint & 1) != 0) { + if ((epint & 1) != 0U) { usb_sam0_ep_isr(ep); } ep++; diff --git a/drivers/usb/device/usb_dc_stm32.c b/drivers/usb/device/usb_dc_stm32.c index 08e30f4abbd..f690fca5968 100644 --- a/drivers/usb/device/usb_dc_stm32.c +++ b/drivers/usb/device/usb_dc_stm32.c @@ -922,7 +922,7 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) if (ep_state->cb) { ep_state->cb(EP0_OUT, USB_DC_EP_SETUP); - if (!(setup->wLength == 0) && + if (!(setup->wLength == 0U) && !(REQTYPE_GET_DIR(setup->bmRequestType) == REQTYPE_DIR_TO_HOST)) { usb_dc_ep_start_read(EP0_OUT, diff --git a/drivers/watchdog/wdog_cmsdk_apb.c b/drivers/watchdog/wdog_cmsdk_apb.c index e071e09486c..b2eebf82f90 100644 --- a/drivers/watchdog/wdog_cmsdk_apb.c +++ b/drivers/watchdog/wdog_cmsdk_apb.c @@ -151,7 +151,7 @@ static int wdog_cmsdk_apb_has_fired(void) { volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT; - return (wdog->maskintstat & CMSDK_APB_WDOG_MASKINTSTAT) != 0; + return (wdog->maskintstat & CMSDK_APB_WDOG_MASKINTSTAT) != 0U; } static void wdog_cmsdk_apb_isr(void) diff --git a/drivers/watchdog/wdt_esp32.c b/drivers/watchdog/wdt_esp32.c index 055abebbd31..ff07b5adbb0 100644 --- a/drivers/watchdog/wdt_esp32.c +++ b/drivers/watchdog/wdt_esp32.c @@ -181,7 +181,7 @@ static int wdt_esp32_install_timeout(struct device *dev, return -ENOTSUP; } - if (cfg->window.min != 0 || cfg->window.max == 0) { + if (cfg->window.min != 0U || cfg->window.max == 0U) { return -EINVAL; } diff --git a/drivers/watchdog/wdt_mcux_wdog.c b/drivers/watchdog/wdt_mcux_wdog.c index 20d93805ece..ab5ef28a0e4 100644 --- a/drivers/watchdog/wdt_mcux_wdog.c +++ b/drivers/watchdog/wdt_mcux_wdog.c @@ -40,10 +40,10 @@ static int mcux_wdog_setup(struct device *dev, u8_t options) } data->wdog_config.workMode.enableStop = - (options & WDT_OPT_PAUSE_IN_SLEEP) == 0; + (options & WDT_OPT_PAUSE_IN_SLEEP) == 0U; data->wdog_config.workMode.enableDebug = - (options & WDT_OPT_PAUSE_HALTED_BY_DBG) == 0; + (options & WDT_OPT_PAUSE_HALTED_BY_DBG) == 0U; WDOG_Init(base, &data->wdog_config); LOG_DBG("Setup the watchdog"); @@ -89,12 +89,12 @@ static int mcux_wdog_install_timeout(struct device *dev, WDOG_GetDefaultConfig(&data->wdog_config); - data->wdog_config.timeoutValue = clock_freq * cfg->window.max / 1000; + data->wdog_config.timeoutValue = clock_freq * cfg->window.max / 1000U; if (cfg->window.min) { data->wdog_config.enableWindowMode = true; data->wdog_config.windowValue = - clock_freq * cfg->window.min / 1000; + clock_freq * cfg->window.min / 1000U; } else { data->wdog_config.enableWindowMode = false; data->wdog_config.windowValue = 0; diff --git a/drivers/watchdog/wdt_nrfx.c b/drivers/watchdog/wdt_nrfx.c index 084095ecc54..f0f9c64abb6 100644 --- a/drivers/watchdog/wdt_nrfx.c +++ b/drivers/watchdog/wdt_nrfx.c @@ -53,7 +53,7 @@ static int wdt_nrf_setup(struct device *dev, u8_t options) * The timeout value given in milliseconds needs to be converted here * to watchdog ticks.*/ nrf_wdt_reload_value_set( - (uint32_t)(((uint64_t)m_timeout * 32768) / 1000)); + (uint32_t)(((uint64_t)m_timeout * 32768U) / 1000)); nrfx_wdt_enable(); @@ -79,18 +79,18 @@ static int wdt_nrf_install_timeout(struct device *dev, return -ENOTSUP; } - if (cfg->window.min != 0) { + if (cfg->window.min != 0U) { return -EINVAL; } - if (m_allocated_channels == 0) { + if (m_allocated_channels == 0U) { /* According to relevant Product Specifications, watchdogs * in all nRF chips can use reload values (determining * the timeout) from range 0xF-0xFFFFFFFF given in 32768 Hz * clock ticks. This makes the allowed range of 0x1-0x07CFFFFF * in milliseconds. Check if the provided value is within * this range. */ - if ((cfg->window.max == 0) || (cfg->window.max > 0x07CFFFFF)) { + if ((cfg->window.max == 0U) || (cfg->window.max > 0x07CFFFFF)) { return -EINVAL; } diff --git a/drivers/watchdog/wdt_qmsi.c b/drivers/watchdog/wdt_qmsi.c index f5217cec46b..7746011edfd 100644 --- a/drivers/watchdog/wdt_qmsi.c +++ b/drivers/watchdog/wdt_qmsi.c @@ -78,7 +78,7 @@ wdt_config_return: static __attribute__((noinline)) u32_t next_pow2(u32_t x) { - if (x <= 2) + if (x <= 2U) return x; return (1ULL << 32) >> __builtin_clz(x - 1); @@ -86,7 +86,7 @@ static __attribute__((noinline)) u32_t next_pow2(u32_t x) static u32_t get_timeout(u32_t timeout) { - u32_t val = timeout / 2; + u32_t val = timeout / 2U; u32_t count = 0U; if (val & (val - 1)) @@ -113,7 +113,7 @@ static int wdt_qmsi_install_timeout(struct device *dev, return -ENOTSUP; } - if (cfg->window.min != 0 || cfg->window.max == 0) { + if (cfg->window.min != 0U || cfg->window.max == 0U) { return -EINVAL; } diff --git a/drivers/watchdog/wdt_sam.c b/drivers/watchdog/wdt_sam.c index 4a1d8edad65..7ee3d3c7916 100644 --- a/drivers/watchdog/wdt_sam.c +++ b/drivers/watchdog/wdt_sam.c @@ -69,12 +69,12 @@ int wdt_sam_convert_timeout(u32_t timeout, u32_t sclk) { u32_t max, min; - timeout = timeout * 1000; + timeout = timeout * 1000U; min = (SAM_PRESCALAR * 1000000) / sclk; max = min * WDT_MAX_VALUE; if ((timeout < min) || (timeout > max)) { LOG_ERR("Invalid timeout value allowed range:" - "%d ms to %d ms", min / 1000, max / 1000); + "%d ms to %d ms", min / 1000U, max / 1000U); return -EINVAL; } @@ -150,7 +150,7 @@ static int wdt_sam_install_timeout(struct device *dev, return -ENOMEM; } - if (cfg->window.min != 0) { + if (cfg->window.min != 0U) { return -EINVAL; } diff --git a/drivers/watchdog/wdt_sam0.c b/drivers/watchdog/wdt_sam0.c index 9e483b5fd76..76ae710ea9a 100644 --- a/drivers/watchdog/wdt_sam0.c +++ b/drivers/watchdog/wdt_sam0.c @@ -35,10 +35,10 @@ static u32_t wdt_sam0_timeout_to_wdt_period(u32_t timeout_ms) u32_t cycles; /* Calculate number of clock cycles @ 1.024 kHz input clock */ - cycles = (timeout_ms * 1024) / 1000; + cycles = (timeout_ms * 1024U) / 1000; /* Minimum wdt period is 8 clock cycles (register value 0) */ - if (cycles <= 8) + if (cycles <= 8U) return 0; /* Round up to next pow2 and calculate the register value */ @@ -141,9 +141,9 @@ static int wdt_sam0_install_timeout(struct device *dev, if (cfg->callback) { if (per == WDT_CONFIG_PER_8_Val) { /* Ensure we have time for the early warning */ - per += 1; + per += 1U; } - WDT_REGS->EWCTRL.bit.EWOFFSET = per - 1; + WDT_REGS->EWCTRL.bit.EWOFFSET = per - 1U; } window = WDT_CONFIG_PER_8_Val; WDT_REGS->CTRL.bit.WEN = 0; diff --git a/drivers/wifi/eswifi/eswifi_bus_spi.c b/drivers/wifi/eswifi/eswifi_bus_spi.c index 9dfae204797..346284b049c 100644 --- a/drivers/wifi/eswifi/eswifi_bus_spi.c +++ b/drivers/wifi/eswifi/eswifi_bus_spi.c @@ -102,7 +102,7 @@ static int eswifi_spi_request(struct eswifi_dev *eswifi, char *cmd, size_t clen, char *rsp, size_t rlen) { struct eswifi_spi_data *spi = eswifi->bus_data; - unsigned int offset = 0, to_read = SPI_READ_CHUNK_SIZE; + unsigned int offset = 0U, to_read = SPI_READ_CHUNK_SIZE; char tmp[2]; int err; @@ -238,7 +238,7 @@ int eswifi_spi_init(struct eswifi_dev *eswifi) spi->spi_cs.gpio_dev = device_get_binding(DT_INVENTEK_ESWIFI_ESWIFI0_CS_GPIO_CONTROLLER); spi->spi_cs.gpio_pin = DT_INVENTEK_ESWIFI_ESWIFI0_CS_GPIO_PIN; - spi->spi_cs.delay = 1000; + spi->spi_cs.delay = 1000U; spi->spi_cfg.cs = &spi->spi_cs; eswifi->bus_data = spi; diff --git a/drivers/wifi/eswifi/eswifi_core.c b/drivers/wifi/eswifi/eswifi_core.c index 7af604f7fe5..2c414339b25 100644 --- a/drivers/wifi/eswifi/eswifi_core.c +++ b/drivers/wifi/eswifi/eswifi_core.c @@ -456,7 +456,7 @@ static int __eswifi_sta_config(struct eswifi_dev *eswifi, } if (params->channel == WIFI_CHANNEL_ANY) { - eswifi->sta.channel = 0; + eswifi->sta.channel = 0U; } else { eswifi->sta.channel = params->channel; } diff --git a/drivers/wifi/simplelink/simplelink_sockets.c b/drivers/wifi/simplelink/simplelink_sockets.c index a9e24a46653..e665655c35b 100644 --- a/drivers/wifi/simplelink/simplelink_sockets.c +++ b/drivers/wifi/simplelink/simplelink_sockets.c @@ -684,7 +684,7 @@ static int simplelink_setsockopt(int sd, int level, int optname, * verification and it is indeed * performed when the cert is set. */ - if (*(u32_t *)optval != 2) { + if (*(u32_t *)optval != 2U) { retval = slcb_SetErrno(ENOTSUP); goto exit; } else { diff --git a/drivers/wifi/winc1500/wifi_winc1500.c b/drivers/wifi/winc1500/wifi_winc1500.c index 197f330c469..15c51bed8a5 100644 --- a/drivers/wifi/winc1500/wifi_winc1500.c +++ b/drivers/wifi/winc1500/wifi_winc1500.c @@ -331,7 +331,7 @@ static int winc1500_bind(struct net_context *context, int ret; /* FIXME atmel winc1500 don't support bind on null port */ - if (net_sin(addr)->sin_port == 0) { + if (net_sin(addr)->sin_port == 0U) { return 0; } diff --git a/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c b/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c index 0a5ba5f4f17..83c82b6b925 100644 --- a/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c +++ b/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c @@ -115,7 +115,7 @@ s8_t nm_bus_init(void *pvinit) } cs_ctrl.gpio_pin = DT_ATMEL_WINC1500_0_CS_GPIO_PIN; - cs_ctrl.delay = 0; + cs_ctrl.delay = 0U; winc1500.spi_cfg.cs = &cs_ctrl; diff --git a/include/arch/arc/v2/arcv2_irq_unit.h b/include/arch/arc/v2/arcv2_irq_unit.h index 99cd5fc83aa..7ab15fb4bbb 100644 --- a/include/arch/arc/v2/arcv2_irq_unit.h +++ b/include/arch/arc/v2/arcv2_irq_unit.h @@ -142,7 +142,7 @@ bool z_arc_v2_irq_unit_is_in_isr(void) return true; } - return ((act & 0xffff) != 0); + return ((act & 0xffff) != 0U); } /* diff --git a/include/arch/arm/cortex_m/mpu/arm_mpu_v8m.h b/include/arch/arm/cortex_m/mpu/arm_mpu_v8m.h index 26f746a2f33..4bf5fc83208 100644 --- a/include/arch/arm/cortex_m/mpu/arm_mpu_v8m.h +++ b/include/arch/arm/cortex_m/mpu/arm_mpu_v8m.h @@ -253,7 +253,7 @@ typedef struct { #define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \ BUILD_ASSERT_MSG((size > 0) && ((u32_t)start % \ - CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0) && \ + CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0U) && \ ((size) % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0), \ " the start and size of the partition must align " \ "with the minimum MPU region size.") diff --git a/include/arch/x86/arch.h b/include/arch/x86/arch.h index a350d495258..3eabc3e5e81 100644 --- a/include/arch/x86/arch.h +++ b/include/arch/x86/arch.h @@ -444,7 +444,7 @@ static ALWAYS_INLINE unsigned int z_arch_irq_lock(void) static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key) { - if ((key & 0x200U) == 0) { + if ((key & 0x200U) == 0U) { return; } diff --git a/include/arch/x86/segmentation.h b/include/arch/x86/segmentation.h index 94262def2fe..b89043ddc9d 100644 --- a/include/arch/x86/segmentation.h +++ b/include/arch/x86/segmentation.h @@ -395,7 +395,7 @@ static inline void z_sd_set_seg_offset(struct segment_descriptor *sd, sd->offset_low = offset & 0xFFFFU; sd->offset_hi = offset >> 16U; sd->segment_selector = segment_selector; - sd->always_0_0 = 0; + sd->always_0_0 = 0U; } @@ -414,7 +414,7 @@ static inline void _init_irq_gate(struct segment_descriptor *sd, z_sd_set_seg_offset(sd, seg_selector, offset); sd->dpl = dpl; sd->descriptor_type = DT_TYPE_SYSTEM; - sd->present = 1; + sd->present = 1U; sd->type = SEG_TYPE_IRQ_GATE; } @@ -522,7 +522,7 @@ static inline void _set_idt(const struct pseudo_descriptor *idt) */ static inline u16_t _get_cs(void) { - u16_t cs = 0; + u16_t cs = 0U; __asm__ __volatile__ ("mov %%cs, %0" : "=r" (cs)); return cs; @@ -536,7 +536,7 @@ static inline u16_t _get_cs(void) */ static inline u16_t _get_ds(void) { - u16_t ds = 0; + u16_t ds = 0U; __asm__ __volatile__ ("mov %%ds, %0" : "=r" (ds)); return ds; diff --git a/include/audio/dmic.h b/include/audio/dmic.h index c4161f6670e..d447193c162 100644 --- a/include/audio/dmic.h +++ b/include/audio/dmic.h @@ -167,7 +167,7 @@ static inline u32_t dmic_build_channel_map(u8_t channel, u8_t pdm, enum pdm_lr lr) { return ((((pdm & BIT_MASK(3)) << 1) | lr) << - ((channel & BIT_MASK(3)) * 4)); + ((channel & BIT_MASK(3)) * 4U)); } /** @@ -190,7 +190,7 @@ static inline void dmic_parse_channel_map(u32_t channel_map_lo, u32_t channel_map; channel_map = (channel < 8) ? channel_map_lo : channel_map_hi; - channel_map >>= ((channel & BIT_MASK(3)) * 4); + channel_map >>= ((channel & BIT_MASK(3)) * 4U); *pdm = (channel >> 1) & BIT_MASK(3); *lr = channel & BIT(0); @@ -209,7 +209,7 @@ static inline void dmic_parse_channel_map(u32_t channel_map_lo, */ static inline u32_t dmic_build_clk_skew_map(u8_t pdm, u8_t skew) { - return ((skew & BIT_MASK(4)) << ((pdm & BIT_MASK(3)) * 4)); + return ((skew & BIT_MASK(4)) << ((pdm & BIT_MASK(3)) * 4U)); } /** diff --git a/include/cmsis_rtos_v1/cmsis_os.h b/include/cmsis_rtos_v1/cmsis_os.h index 4b6277fabdb..1af863e6678 100644 --- a/include/cmsis_rtos_v1/cmsis_os.h +++ b/include/cmsis_rtos_v1/cmsis_os.h @@ -266,7 +266,7 @@ uint32_t osKernelSysTick (void); /// Convert a microseconds value to a RTOS kernel system timer value. /// \param microsec time value in microseconds. /// \return time value normalized to the \ref osKernelSysTickFrequency -#define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000) +#define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000U) #endif // System Timer available diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 96af98a9a92..6232c728e18 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -112,17 +112,17 @@ static inline int cipher_begin_session(struct device *dev, ctx->ops.cipher_mode = mode; flags = (ctx->flags & (CAP_OPAQUE_KEY_HNDL | CAP_RAW_KEY)); - __ASSERT(flags != 0, "Keytype missing: RAW Key or OPAQUE handle"); + __ASSERT(flags != 0U, "Keytype missing: RAW Key or OPAQUE handle"); __ASSERT(flags != (CAP_OPAQUE_KEY_HNDL | CAP_RAW_KEY), "conflicting options for keytype"); flags = (ctx->flags & (CAP_INPLACE_OPS | CAP_SEPARATE_IO_BUFS)); - __ASSERT(flags != 0, "IO buffer type missing"); + __ASSERT(flags != 0U, "IO buffer type missing"); __ASSERT(flags != (CAP_INPLACE_OPS | CAP_SEPARATE_IO_BUFS), "conflicting options for IO buffer type"); flags = (ctx->flags & (CAP_SYNC_OPS | CAP_ASYNC_OPS)); - __ASSERT(flags != 0, "sync/async type missing"); + __ASSERT(flags != 0U, "sync/async type missing"); __ASSERT(flags != (CAP_SYNC_OPS | CAP_ASYNC_OPS), "conflicting options for sync/async"); diff --git a/include/i2c.h b/include/i2c.h index 7cfaa684002..48820786ab4 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -511,7 +511,7 @@ static inline int i2c_burst_write(struct device *dev, struct i2c_msg msg[2]; msg[0].buf = &start_addr; - msg[0].len = 1; + msg[0].len = 1U; msg[0].flags = I2C_MSG_WRITE; msg[1].buf = (u8_t *)buf; @@ -673,7 +673,7 @@ __deprecated static inline int i2c_burst_write16(struct device *dev, addr_buffer[1] = start_addr & 0xFF; addr_buffer[0] = start_addr >> 8; msg[0].buf = addr_buffer; - msg[0].len = 2; + msg[0].len = 2U; msg[0].flags = I2C_MSG_WRITE; msg[1].buf = (u8_t *)buf; diff --git a/include/kernel.h b/include/kernel.h index dde02ceff91..dcf649366d3 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -3098,7 +3098,7 @@ __syscall void k_sem_reset(struct k_sem *sem); */ static inline void z_impl_k_sem_reset(struct k_sem *sem) { - sem->count = 0; + sem->count = 0U; } /** @@ -4397,7 +4397,7 @@ __syscall void k_poll_signal_reset(struct k_poll_signal *signal); static inline void z_impl_k_poll_signal_reset(struct k_poll_signal *signal) { - signal->signaled = 0; + signal->signaled = 0U; } /** diff --git a/include/logging/log_msg.h b/include/logging/log_msg.h index 6874c0b1981..7dee2e9cad7 100644 --- a/include/logging/log_msg.h +++ b/include/logging/log_msg.h @@ -339,7 +339,7 @@ static inline struct log_msg *z_log_msg_std_alloc(void) if (msg != NULL) { /* all fields reset to 0, reference counter to 1 */ msg->hdr.ref_cnt = 1; - msg->hdr.params.raw = 0; + msg->hdr.params.raw = 0U; msg->hdr.params.std.type = LOG_MSG_TYPE_STD; } @@ -385,7 +385,7 @@ static inline struct log_msg *log_msg_create_1(const char *str, if (msg != NULL) { msg->str = str; - msg->hdr.params.std.nargs = 1; + msg->hdr.params.std.nargs = 1U; msg->payload.single.args[0] = arg1; } @@ -414,7 +414,7 @@ static inline struct log_msg *log_msg_create_2(const char *str, if (msg != NULL) { msg->str = str; - msg->hdr.params.std.nargs = 2; + msg->hdr.params.std.nargs = 2U; msg->payload.single.args[0] = arg1; msg->payload.single.args[1] = arg2; } @@ -446,7 +446,7 @@ static inline struct log_msg *log_msg_create_3(const char *str, if (msg != NULL) { msg->str = str; - msg->hdr.params.std.nargs = 3; + msg->hdr.params.std.nargs = 3U; msg->payload.single.args[0] = arg1; msg->payload.single.args[1] = arg2; msg->payload.single.args[2] = arg3; diff --git a/include/misc/sflist.h b/include/misc/sflist.h index 69c9a368c96..5bde377293b 100644 --- a/include/misc/sflist.h +++ b/include/misc/sflist.h @@ -281,7 +281,7 @@ static inline u8_t sys_sfnode_flags_get(sys_sfnode_t *node) */ static inline void sys_sfnode_init(sys_sfnode_t *node, u8_t flags) { - __ASSERT((flags & ~SYS_SFLIST_FLAGS_MASK) == 0, "flags too large"); + __ASSERT((flags & ~SYS_SFLIST_FLAGS_MASK) == 0U, "flags too large"); node->next_and_flags = flags; } @@ -297,7 +297,7 @@ static inline void sys_sfnode_init(sys_sfnode_t *node, u8_t flags) */ static inline void sys_sfnode_flags_set(sys_sfnode_t *node, u8_t flags) { - __ASSERT((flags & ~SYS_SFLIST_FLAGS_MASK) == 0, "flags too large"); + __ASSERT((flags & ~SYS_SFLIST_FLAGS_MASK) == 0U, "flags too large"); node->next_and_flags = (unative_t)(z_sfnode_next_peek(node)) | flags; } diff --git a/include/misc/stack.h b/include/misc/stack.h index 84f521117bf..6437e662325 100644 --- a/include/misc/stack.h +++ b/include/misc/stack.h @@ -67,7 +67,7 @@ static inline void stack_analyze(const char *name, const char *stack, LOG_MODULE_DECLARE(kernel, CONFIG_KERNEL_LOG_LEVEL); unsigned int unused = stack_unused_space_get(stack, size); - unsigned int pcnt = ((size - unused) * 100) / size; + unsigned int pcnt = ((size - unused) * 100U) / size; LOG_INF("%s :\tunused %u\tusage %u / %u (%u %%)", name, unused, size - unused, size, pcnt); diff --git a/include/net/buf.h b/include/net/buf.h index e3209f7667b..7d12ed711ab 100644 --- a/include/net/buf.h +++ b/include/net/buf.h @@ -137,7 +137,7 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf, } buf->data = buf->__buf + reserve_head; - buf->len = 0; + buf->len = 0U; } /** @@ -149,7 +149,7 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf, */ static inline void net_buf_simple_reset(struct net_buf_simple *buf) { - buf->len = 0; + buf->len = 0U; buf->data = buf->__buf; } diff --git a/include/net/net_context.h b/include/net/net_context.h index a43a9118392..e4c0b92a86e 100644 --- a/include/net/net_context.h +++ b/include/net/net_context.h @@ -377,7 +377,7 @@ static inline sa_family_t net_context_get_family(struct net_context *context) static inline void net_context_set_family(struct net_context *context, sa_family_t family) { - u8_t flag = 0; + u8_t flag = 0U; NET_ASSERT(context); @@ -420,7 +420,7 @@ enum net_sock_type net_context_get_type(struct net_context *context) static inline void net_context_set_type(struct net_context *context, enum net_sock_type type) { - u16_t flag = 0; + u16_t flag = 0U; NET_ASSERT(context); diff --git a/include/net/net_ip.h b/include/net/net_ip.h index 60fddf2c4b5..3fcf1d91809 100644 --- a/include/net/net_ip.h +++ b/include/net/net_ip.h @@ -563,7 +563,7 @@ static inline bool net_ipv6_is_prefix(const u8_t *addr1, u8_t length) { u8_t bits = 128 - length; - u8_t bytes = length / 8; + u8_t bytes = length / 8U; u8_t remain = bits % 8; u8_t mask; @@ -597,7 +597,7 @@ static inline bool net_ipv6_is_prefix(const u8_t *addr1, */ static inline bool net_ipv4_is_addr_loopback(struct in_addr *addr) { - return addr->s4_addr[0] == 127; + return addr->s4_addr[0] == 127U; } /** @@ -913,7 +913,7 @@ void net_ipv6_addr_create_solicited_node(const struct in6_addr *src, UNALIGNED_PUT(0, &dst->s6_addr16[2]); UNALIGNED_PUT(0, &dst->s6_addr16[3]); UNALIGNED_PUT(0, &dst->s6_addr16[4]); - dst->s6_addr[10] = 0; + dst->s6_addr[10] = 0U; dst->s6_addr[11] = 0x01; dst->s6_addr[12] = 0xFF; dst->s6_addr[13] = src->s6_addr[13]; @@ -981,7 +981,7 @@ static inline void net_ipv6_addr_create_iid(struct in6_addr *addr, UNALIGNED_PUT(0, &addr->s6_addr32[2]); addr->s6_addr[11] = 0xff; addr->s6_addr[12] = 0xfe; - addr->s6_addr[13] = 0; + addr->s6_addr[13] = 0U; addr->s6_addr[14] = lladdr->addr[0]; addr->s6_addr[15] = lladdr->addr[1]; } @@ -1032,9 +1032,9 @@ static inline bool net_ipv6_addr_based_on_ll(const struct in6_addr *addr, switch (lladdr->len) { case 2: if (!memcmp(&addr->s6_addr[14], lladdr->addr, lladdr->len) && - addr->s6_addr[8] == 0 && - addr->s6_addr[9] == 0 && - addr->s6_addr[10] == 0 && + addr->s6_addr[8] == 0U && + addr->s6_addr[9] == 0U && + addr->s6_addr[10] == 0U && addr->s6_addr[11] == 0xff && addr->s6_addr[12] == 0xfe) { return true; diff --git a/include/net/net_pkt.h b/include/net/net_pkt.h index e63765026cc..2c0b46d3e03 100644 --- a/include/net/net_pkt.h +++ b/include/net/net_pkt.h @@ -728,7 +728,7 @@ static inline void net_pkt_lladdr_swap(struct net_pkt *pkt) static inline void net_pkt_lladdr_clear(struct net_pkt *pkt) { net_pkt_lladdr_src(pkt)->addr = NULL; - net_pkt_lladdr_src(pkt)->len = 0; + net_pkt_lladdr_src(pkt)->len = 0U; } #if defined(CONFIG_IEEE802154) || defined(CONFIG_IEEE802154_RAW_MODE) diff --git a/include/net/trickle.h b/include/net/trickle.h index 4f32c839ed7..530915757a7 100644 --- a/include/net/trickle.h +++ b/include/net/trickle.h @@ -136,7 +136,7 @@ static inline bool net_trickle_is_running(struct net_trickle *trickle) { NET_ASSERT(trickle); - return trickle->I != 0; + return trickle->I != 0U; } /** diff --git a/include/power.h b/include/power.h index 77d078a8175..bf70b000b32 100644 --- a/include/power.h +++ b/include/power.h @@ -140,7 +140,7 @@ static inline bool sys_pm_is_deep_sleep_state(enum power_states state) */ static inline void _sys_pm_idle_exit_notification_disable(void) { - sys_pm_idle_exit_notify = 0; + sys_pm_idle_exit_notify = 0U; } /** diff --git a/include/ring_buffer.h b/include/ring_buffer.h index 392519e2390..bad1209c0a7 100644 --- a/include/ring_buffer.h +++ b/include/ring_buffer.h @@ -152,7 +152,7 @@ static inline void ring_buf_init(struct ring_buf *buf, u32_t size, void *data) if (is_power_of_two(size)) { buf->mask = size - 1; } else { - buf->mask = 0; + buf->mask = 0U; } } diff --git a/include/rtc.h b/include/rtc.h index 7d7196d485d..69438127f4d 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -101,7 +101,7 @@ __deprecated static inline int rtc_set_config(struct device *dev, err = counter_set_top_value(dev, cfg->alarm_val, rtc_counter_top_callback, cfg->cb_fn); - if (err == 0 && cfg->alarm_enable != 0) { + if (err == 0 && cfg->alarm_enable != 0U) { err = counter_start(dev); } diff --git a/kernel/device.c b/kernel/device.c index 85d5b1604f2..03dc2868c33 100644 --- a/kernel/device.c +++ b/kernel/device.c @@ -131,7 +131,7 @@ int device_any_busy_check(void) int i = 0; for (i = 0; i < DEVICE_BUSY_SIZE; i++) { - if (__device_busy_start[i] != 0) { + if (__device_busy_start[i] != 0U) { return -EBUSY; } } diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index f38b21abbe7..7d8fd55a062 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -95,7 +95,7 @@ static inline bool z_is_thread_prevented_from_running(struct k_thread *thread) u8_t state = thread->base.thread_state; return (state & (_THREAD_PENDING | _THREAD_PRESTART | _THREAD_DEAD | - _THREAD_DUMMY | _THREAD_SUSPENDED)) != 0; + _THREAD_DUMMY | _THREAD_SUSPENDED)) != 0U; } @@ -112,7 +112,7 @@ static inline bool z_is_thread_ready(struct k_thread *thread) static inline bool z_has_thread_started(struct k_thread *thread) { - return (thread->base.thread_state & _THREAD_PRESTART) == 0; + return (thread->base.thread_state & _THREAD_PRESTART) == 0U; } static inline bool z_is_thread_state_set(struct k_thread *thread, u32_t state) diff --git a/kernel/init.c b/kernel/init.c index b33af62707a..c43c90454ac 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -295,7 +295,7 @@ void __weak main(void) static void init_idle_thread(struct k_thread *thr, k_thread_stack_t *stack) { #ifdef CONFIG_SMP - thr->base.is_idle = 1; + thr->base.is_idle = 1U; #endif z_setup_new_thread(thr, stack, @@ -341,8 +341,8 @@ static void prepare_multithreading(struct k_thread *dummy_thread) dummy_thread->base.user_options = K_ESSENTIAL; dummy_thread->base.thread_state = _THREAD_DUMMY; #ifdef CONFIG_THREAD_STACK_INFO - dummy_thread->stack_info.start = 0; - dummy_thread->stack_info.size = 0; + dummy_thread->stack_info.start = 0U; + dummy_thread->stack_info.size = 0U; #endif #ifdef CONFIG_USERSPACE dummy_thread->mem_domain_info.mem_domain = 0; diff --git a/kernel/int_latency_bench.c b/kernel/int_latency_bench.c index 97435b5b653..c2a2a9b6f2a 100644 --- a/kernel/int_latency_bench.c +++ b/kernel/int_latency_bench.c @@ -176,7 +176,7 @@ void int_latency_show(void) { u32_t intHandlerLatency = 0U; - if (int_latency_bench_ready == 0) { + if (int_latency_bench_ready == 0U) { printk("error: int_latency_init() has not been invoked\n"); return; } diff --git a/kernel/mailbox.c b/kernel/mailbox.c index f04a0cba9e3..3668025cb7a 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c @@ -204,7 +204,7 @@ static void mbox_message_dispose(struct k_mbox_msg *rx_msg) * asynchronous send: free asynchronous message descriptor + * dummy thread pair, then give semaphore (if needed) */ - if ((sending_thread->base.thread_state & _THREAD_DUMMY) != 0) { + if ((sending_thread->base.thread_state & _THREAD_DUMMY) != 0U) { struct k_sem *async_sem = tx_msg->_async_sem; mbox_async_free((struct k_mbox_async *)sending_thread); @@ -274,7 +274,7 @@ static int mbox_message_put(struct k_mbox *mbox, struct k_mbox_msg *tx_msg, * until the receiver consumes the message */ if ((sending_thread->base.thread_state & _THREAD_DUMMY) - != 0) { + != 0U) { z_reschedule(&mbox->lock, key); return 0; } @@ -297,7 +297,7 @@ static int mbox_message_put(struct k_mbox *mbox, struct k_mbox_msg *tx_msg, #if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0) /* asynchronous send: dummy thread waits on tx queue for receiver */ - if ((sending_thread->base.thread_state & _THREAD_DUMMY) != 0) { + if ((sending_thread->base.thread_state & _THREAD_DUMMY) != 0U) { z_pend_thread(sending_thread, &mbox->tx_msg_queue, K_FOREVER); k_spin_unlock(&mbox->lock, key); return 0; diff --git a/kernel/mem_domain.c b/kernel/mem_domain.c index 220cf37267b..937131d65db 100644 --- a/kernel/mem_domain.c +++ b/kernel/mem_domain.c @@ -86,15 +86,15 @@ void k_mem_domain_init(struct k_mem_domain *domain, u8_t num_parts, k_spinlock_key_t key; __ASSERT(domain != NULL, ""); - __ASSERT(num_parts == 0 || parts != NULL, ""); + __ASSERT(num_parts == 0U || parts != NULL, ""); __ASSERT(num_parts <= max_partitions, ""); key = k_spin_lock(&lock); - domain->num_partitions = 0; + domain->num_partitions = 0U; (void)memset(domain->partitions, 0, sizeof(domain->partitions)); - if (num_parts != 0) { + if (num_parts != 0U) { u32_t i; for (i = 0U; i < num_parts; i++) { @@ -167,7 +167,7 @@ void k_mem_domain_add_partition(struct k_mem_domain *domain, for (p_idx = 0; p_idx < max_partitions; p_idx++) { /* A zero-sized partition denotes it's a free partition */ - if (domain->partitions[p_idx].size == 0) { + if (domain->partitions[p_idx].size == 0U) { break; } } @@ -221,7 +221,7 @@ void k_mem_domain_remove_partition(struct k_mem_domain *domain, } /* A zero-sized partition denotes it's a free partition */ - domain->partitions[p_idx].size = 0; + domain->partitions[p_idx].size = 0U; domain->num_partitions--; diff --git a/kernel/mem_slab.c b/kernel/mem_slab.c index b4ecb7815a0..b78aef0a59f 100644 --- a/kernel/mem_slab.c +++ b/kernel/mem_slab.c @@ -82,7 +82,7 @@ void k_mem_slab_init(struct k_mem_slab *slab, void *buffer, slab->num_blocks = num_blocks; slab->block_size = block_size; slab->buffer = buffer; - slab->num_used = 0; + slab->num_used = 0U; create_free_list(slab); z_waitq_init(&slab->wait_q); SYS_TRACING_OBJ_INIT(k_mem_slab, slab); diff --git a/kernel/mutex.c b/kernel/mutex.c index 27d3cf88802..c6225b62fd3 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -74,7 +74,7 @@ SYS_INIT(init_mutex_module, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS); void z_impl_k_mutex_init(struct k_mutex *mutex) { mutex->owner = NULL; - mutex->lock_count = 0; + mutex->lock_count = 0U; sys_trace_void(SYS_TRACE_ID_MUTEX_INIT); @@ -247,7 +247,7 @@ void z_impl_k_mutex_unlock(struct k_mutex *mutex) */ mutex->owner_orig_prio = new_owner->base.prio; } else { - mutex->lock_count = 0; + mutex->lock_count = 0U; k_spin_unlock(&lock, key); } diff --git a/kernel/pipes.c b/kernel/pipes.c index 5dada6fb6a8..e882fdc2e67 100644 --- a/kernel/pipes.c +++ b/kernel/pipes.c @@ -414,7 +414,7 @@ static int pipe_return_code(size_t min_xfer, size_t bytes_remaining, static void pipe_thread_ready(struct k_thread *thread) { #if (CONFIG_NUM_PIPE_ASYNC_MSGS > 0) - if ((thread->base.thread_state & _THREAD_DUMMY) != 0) { + if ((thread->base.thread_state & _THREAD_DUMMY) != 0U) { pipe_async_finish((struct k_pipe_async *)thread); return; } diff --git a/kernel/poll.c b/kernel/poll.c index a51fa95b80b..682ee79593a 100644 --- a/kernel/poll.c +++ b/kernel/poll.c @@ -48,7 +48,7 @@ void k_poll_event_init(struct k_poll_event *event, u32_t type, event->type = type; event->state = K_POLL_STATE_NOT_READY; event->mode = mode; - event->unused = 0; + event->unused = 0U; event->obj = obj; } @@ -69,7 +69,7 @@ static inline bool is_condition_met(struct k_poll_event *event, u32_t *state) } break; case K_POLL_TYPE_SIGNAL: - if (event->signal->signaled != 0) { + if (event->signal->signaled != 0U) { *state = K_POLL_STATE_SIGNALED; return true; } @@ -384,7 +384,7 @@ void z_handle_obj_poll_events(sys_dlist_t *events, u32_t state) void z_impl_k_poll_signal_init(struct k_poll_signal *signal) { sys_dlist_init(&signal->poll_events); - signal->signaled = 0; + signal->signaled = 0U; /* signal->result is left unitialized */ z_object_init(signal); } @@ -424,7 +424,7 @@ int z_impl_k_poll_signal_raise(struct k_poll_signal *signal, int result) struct k_poll_event *poll_event; signal->result = result; - signal->signaled = 1; + signal->signaled = 1U; poll_event = (struct k_poll_event *)sys_dlist_get(&signal->poll_events); if (poll_event == NULL) { diff --git a/kernel/sched.c b/kernel/sched.c index 1c28eb688e7..bc4ad520463 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1032,7 +1032,7 @@ void z_sched_abort(struct k_thread *thread) /* Wait for it to be flagged dead either by the CPU it was * running on or because we caught it idle in the queue */ - while ((thread->base.thread_state & _THREAD_DEAD) == 0) { + while ((thread->base.thread_state & _THREAD_DEAD) == 0U) { LOCKED(&sched_spinlock) { if (z_is_thread_queued(thread)) { thread->base.thread_state |= _THREAD_DEAD; diff --git a/kernel/thread.c b/kernel/thread.c index f96dbdc2f19..555d931d61c 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -413,7 +413,7 @@ void z_setup_new_thread(struct k_thread *new_thread, new_thread); } - if ((options & K_INHERIT_PERMS) != 0) { + if ((options & K_INHERIT_PERMS) != 0U) { z_thread_perms_inherit(_current, new_thread); } #endif @@ -678,7 +678,7 @@ void z_init_thread_base(struct _thread_base *thread_base, int priority, thread_base->prio = priority; - thread_base->sched_locked = 0; + thread_base->sched_locked = 0U; /* swap_data does not need to be initialized */ diff --git a/kernel/thread_abort.c b/kernel/thread_abort.c index 162f519c6de..eeb3db9f84c 100644 --- a/kernel/thread_abort.c +++ b/kernel/thread_abort.c @@ -37,7 +37,7 @@ void z_impl_k_thread_abort(k_tid_t thread) struct k_spinlock lock = {}; k_spinlock_key_t key = k_spin_lock(&lock); - __ASSERT((thread->base.user_options & K_ESSENTIAL) == 0, + __ASSERT((thread->base.user_options & K_ESSENTIAL) == 0U, "essential thread aborted"); z_thread_single_abort(thread); diff --git a/kernel/timer.c b/kernel/timer.c index 776181c5512..6bf8a54fb8a 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -62,7 +62,7 @@ void z_timer_expiration_handler(struct _timeout *t) } /* update timer's status */ - timer->status += 1; + timer->status += 1U; /* invoke timer expiry function */ if (timer->expiry_fn != NULL) { @@ -97,7 +97,7 @@ void k_timer_init(struct k_timer *timer, { timer->expiry_fn = expiry_fn; timer->stop_fn = stop_fn; - timer->status = 0; + timer->status = 0U; z_waitq_init(&timer->wait_q); z_init_timeout(&timer->timeout, z_timer_expiration_handler); @@ -121,7 +121,7 @@ void z_impl_k_timer_start(struct k_timer *timer, s32_t duration, s32_t period) (void)z_abort_timeout(&timer->timeout); timer->period = period_in_ticks; - timer->status = 0; + timer->status = 0U; z_add_timeout(&timer->timeout, z_timer_expiration_handler, duration_in_ticks); } @@ -171,7 +171,7 @@ u32_t z_impl_k_timer_status_get(struct k_timer *timer) k_spinlock_key_t key = k_spin_lock(&lock); u32_t result = timer->status; - timer->status = 0; + timer->status = 0U; k_spin_unlock(&lock, key); return result; @@ -188,7 +188,7 @@ u32_t z_impl_k_timer_status_sync(struct k_timer *timer) k_spinlock_key_t key = k_spin_lock(&lock); u32_t result = timer->status; - if (result == 0) { + if (result == 0U) { if (!z_is_inactive_timeout(&timer->timeout)) { /* wait for timer to expire or stop */ (void)z_pend_curr(&lock, key, &timer->wait_q, K_FOREVER); @@ -203,7 +203,7 @@ u32_t z_impl_k_timer_status_sync(struct k_timer *timer) /* timer has already expired at least once */ } - timer->status = 0; + timer->status = 0U; k_spin_unlock(&lock, key); return result; diff --git a/kernel/userspace.c b/kernel/userspace.c index a39f41df57b..0d1c9548fd8 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -370,12 +370,12 @@ static void unref_check(struct _k_object *ko, int index) struct dyn_obj *dyn_obj = CONTAINER_OF(ko, struct dyn_obj, kobj); - if ((ko->flags & K_OBJ_FLAG_ALLOC) == 0) { + if ((ko->flags & K_OBJ_FLAG_ALLOC) == 0U) { goto out; } for (int i = 0; i < CONFIG_MAX_THREAD_BYTES; i++) { - if (ko->perms[i] != 0) { + if (ko->perms[i] != 0U) { goto out; } } @@ -470,7 +470,7 @@ static int thread_perms_test(struct _k_object *ko) { int index; - if ((ko->flags & K_OBJ_FLAG_PUBLIC) != 0) { + if ((ko->flags & K_OBJ_FLAG_PUBLIC) != 0U) { return 1; } diff --git a/lib/cmsis_rtos_v1/cmsis_mailq.c b/lib/cmsis_rtos_v1/cmsis_mailq.c index e0e54e79bf0..cc62bb2747b 100644 --- a/lib/cmsis_rtos_v1/cmsis_mailq.c +++ b/lib/cmsis_rtos_v1/cmsis_mailq.c @@ -37,7 +37,7 @@ void *osMailAlloc(osMailQId queue_id, uint32_t millisec) return NULL; } - if (millisec == 0) { + if (millisec == 0U) { retval = k_mem_slab_alloc( (struct k_mem_slab *)(queue_def->pool), (void **)&ptr, K_NO_WAIT); @@ -71,7 +71,7 @@ void *osMailCAlloc(osMailQId queue_id, uint32_t millisec) return NULL; } - if (millisec == 0) { + if (millisec == 0U) { retval = k_mem_slab_alloc( (struct k_mem_slab *)(queue_def->pool), (void **)&ptr, K_NO_WAIT); @@ -137,7 +137,7 @@ osEvent osMailGet(osMailQId queue_id, uint32_t millisec) mmsg.rx_source_thread = K_ANY; mmsg.tx_target_thread = K_ANY; - if (millisec == 0) { + if (millisec == 0U) { retval = k_mbox_get(queue_def->mbox, &mmsg, NULL, K_NO_WAIT); } else if (millisec == osWaitForever) { retval = k_mbox_get(queue_def->mbox, &mmsg, NULL, K_FOREVER); diff --git a/lib/cmsis_rtos_v1/cmsis_msgq.c b/lib/cmsis_rtos_v1/cmsis_msgq.c index 45b5d078974..5e3869c9a71 100644 --- a/lib/cmsis_rtos_v1/cmsis_msgq.c +++ b/lib/cmsis_rtos_v1/cmsis_msgq.c @@ -38,7 +38,7 @@ osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec) return osErrorParameter; } - if (millisec == 0) { + if (millisec == 0U) { retval = k_msgq_put(queue_def->msgq, (void *)&info, K_NO_WAIT); } else if (millisec == osWaitForever) { retval = k_msgq_put(queue_def->msgq, (void *)&info, K_FOREVER); @@ -70,7 +70,7 @@ osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec) return evt; } - if (millisec == 0) { + if (millisec == 0U) { retval = k_msgq_get(queue_def->msgq, &info, K_NO_WAIT); } else if (millisec == osWaitForever) { retval = k_msgq_get(queue_def->msgq, &info, K_FOREVER); diff --git a/lib/cmsis_rtos_v1/cmsis_mutex.c b/lib/cmsis_rtos_v1/cmsis_mutex.c index a7b185563d1..044258c45fa 100644 --- a/lib/cmsis_rtos_v1/cmsis_mutex.c +++ b/lib/cmsis_rtos_v1/cmsis_mutex.c @@ -54,7 +54,7 @@ osStatus osMutexWait(osMutexId mutex_id, uint32_t timeout) if (timeout == osWaitForever) { status = k_mutex_lock(mutex, K_FOREVER); - } else if (timeout == 0) { + } else if (timeout == 0U) { status = k_mutex_lock(mutex, K_NO_WAIT); } else { status = k_mutex_lock(mutex, timeout); diff --git a/lib/cmsis_rtos_v1/cmsis_semaphore.c b/lib/cmsis_rtos_v1/cmsis_semaphore.c index f4e53a9cb11..6896fd755c6 100644 --- a/lib/cmsis_rtos_v1/cmsis_semaphore.c +++ b/lib/cmsis_rtos_v1/cmsis_semaphore.c @@ -56,7 +56,7 @@ int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t timeout) if (timeout == osWaitForever) { status = k_sem_take(semaphore, K_FOREVER); - } else if (timeout == 0) { + } else if (timeout == 0U) { status = k_sem_take(semaphore, K_NO_WAIT); } else { status = k_sem_take(semaphore, timeout); diff --git a/lib/cmsis_rtos_v1/cmsis_signal.c b/lib/cmsis_rtos_v1/cmsis_signal.c index c0e6616243a..a0cfa37fa55 100644 --- a/lib/cmsis_rtos_v1/cmsis_signal.c +++ b/lib/cmsis_rtos_v1/cmsis_signal.c @@ -110,7 +110,7 @@ osEvent osSignalWait(int32_t signals, uint32_t millisec) evt.status = osEventSignal; break; case -EAGAIN: - if (millisec == 0) { + if (millisec == 0U) { evt.status = osOK; } else { evt.status = osEventTimeout; diff --git a/lib/cmsis_rtos_v1/cmsis_thread.c b/lib/cmsis_rtos_v1/cmsis_thread.c index 9bf1d6a7ac2..2b50ea82e90 100644 --- a/lib/cmsis_rtos_v1/cmsis_thread.c +++ b/lib/cmsis_rtos_v1/cmsis_thread.c @@ -68,7 +68,7 @@ osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *arg) "invalid priority\n"); stacksz = thread_def->stacksize; - if (stacksz == 0) { + if (stacksz == 0U) { stacksz = CONFIG_CMSIS_THREAD_MAX_STACK_SIZE; } diff --git a/lib/cmsis_rtos_v2/event_flags.c b/lib/cmsis_rtos_v2/event_flags.c index dbcddc378b1..61311fc277c 100644 --- a/lib/cmsis_rtos_v2/event_flags.c +++ b/lib/cmsis_rtos_v2/event_flags.c @@ -45,7 +45,7 @@ osEventFlagsId_t osEventFlagsNew(const osEventFlagsAttr_t *attr) k_poll_signal_init(&events->poll_signal); k_poll_event_init(&events->poll_event, K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &events->poll_signal); - events->signal_results = 0; + events->signal_results = 0U; if (attr->name == NULL) { strncpy(events->name, init_event_flags_attrs.name, @@ -147,11 +147,11 @@ uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, __ASSERT(events->poll_event.state == K_POLL_STATE_SIGNALED, "event state not signalled!"); - __ASSERT(events->poll_event.signal->signaled == 1, + __ASSERT(events->poll_event.signal->signaled == 1U, "event signaled is not 1"); /* Reset the states to facilitate the next trigger */ - events->poll_event.signal->signaled = 0; + events->poll_event.signal->signaled = 0U; events->poll_event.state = K_POLL_STATE_NOT_READY; if (options & osFlagsWaitAll) { @@ -178,7 +178,7 @@ uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, if (timeout_ms > time_delta_ms) { timeout_ms -= time_delta_ms; } else { - timeout_ms = 0; + timeout_ms = 0U; } } else { break; diff --git a/lib/cmsis_rtos_v2/mempool.c b/lib/cmsis_rtos_v2/mempool.c index b4e3806dfa8..e12199c0041 100644 --- a/lib/cmsis_rtos_v2/mempool.c +++ b/lib/cmsis_rtos_v2/mempool.c @@ -97,7 +97,7 @@ void *osMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout) return NULL; } - if (timeout == 0) { + if (timeout == 0U) { retval = k_mem_slab_alloc( (struct k_mem_slab *)(&mslab->z_mslab), (void **)&ptr, K_NO_WAIT); diff --git a/lib/cmsis_rtos_v2/msgq.c b/lib/cmsis_rtos_v2/msgq.c index 3f2419f3950..1374e162d92 100644 --- a/lib/cmsis_rtos_v2/msgq.c +++ b/lib/cmsis_rtos_v2/msgq.c @@ -97,7 +97,7 @@ osStatus_t osMessageQueuePut(osMessageQueueId_t msgq_id, const void *msg_ptr, return osErrorParameter; } - if (timeout == 0) { + if (timeout == 0U) { retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr, K_NO_WAIT); } else if (timeout == osWaitForever) { retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr, K_FOREVER); @@ -135,7 +135,7 @@ osStatus_t osMessageQueueGet(osMessageQueueId_t msgq_id, void *msg_ptr, return osErrorParameter; } - if (timeout == 0) { + if (timeout == 0U) { retval = k_msgq_get(&msgq->z_msgq, msg_ptr, K_NO_WAIT); } else if (timeout == osWaitForever) { retval = k_msgq_get(&msgq->z_msgq, msg_ptr, K_FOREVER); diff --git a/lib/cmsis_rtos_v2/mutex.c b/lib/cmsis_rtos_v2/mutex.c index 81bbaaa1d49..4aa44c5a09d 100644 --- a/lib/cmsis_rtos_v2/mutex.c +++ b/lib/cmsis_rtos_v2/mutex.c @@ -73,23 +73,23 @@ osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) return osErrorISR; } - if (mutex->z_mutex.lock_count == 0 || + if (mutex->z_mutex.lock_count == 0U || mutex->z_mutex.owner == _current) { } /* Throw an error if the mutex is not configured to be recursive and * the current thread is trying to acquire the mutex again. */ - if ((mutex->state & osMutexRecursive) == 0) { + if ((mutex->state & osMutexRecursive) == 0U) { if ((mutex->z_mutex.owner == _current) && - (mutex->z_mutex.lock_count != 0)) { + (mutex->z_mutex.lock_count != 0U)) { return osErrorResource; } } if (timeout == osWaitForever) { status = k_mutex_lock(&mutex->z_mutex, K_FOREVER); - } else if (timeout == 0) { + } else if (timeout == 0U) { status = k_mutex_lock(&mutex->z_mutex, K_NO_WAIT); } else { status = k_mutex_lock(&mutex->z_mutex, @@ -121,7 +121,7 @@ osStatus_t osMutexRelease(osMutexId_t mutex_id) } /* Mutex was not obtained before or was not owned by current thread */ - if ((mutex->z_mutex.lock_count == 0) || + if ((mutex->z_mutex.lock_count == 0U) || (mutex->z_mutex.owner != _current)) { return osErrorResource; } @@ -165,7 +165,7 @@ osThreadId_t osMutexGetOwner(osMutexId_t mutex_id) } /* Mutex was not obtained before */ - if (mutex->z_mutex.lock_count == 0) { + if (mutex->z_mutex.lock_count == 0U) { return NULL; } diff --git a/lib/cmsis_rtos_v2/semaphore.c b/lib/cmsis_rtos_v2/semaphore.c index b91230ccf69..3de1c3e021c 100644 --- a/lib/cmsis_rtos_v2/semaphore.c +++ b/lib/cmsis_rtos_v2/semaphore.c @@ -72,7 +72,7 @@ osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout) if (timeout == osWaitForever) { status = k_sem_take(&semaphore->z_semaphore, K_FOREVER); - } else if (timeout == 0) { + } else if (timeout == 0U) { status = k_sem_take(&semaphore->z_semaphore, K_NO_WAIT); } else { status = k_sem_take(&semaphore->z_semaphore, diff --git a/lib/cmsis_rtos_v2/thread.c b/lib/cmsis_rtos_v2/thread.c index e7d504427b8..19cce685e03 100644 --- a/lib/cmsis_rtos_v2/thread.c +++ b/lib/cmsis_rtos_v2/thread.c @@ -178,12 +178,12 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg, k_poll_signal_init(&tid->poll_signal); k_poll_event_init(&tid->poll_event, K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &tid->poll_signal); - tid->signal_results = 0; + tid->signal_results = 0U; /* TODO: Do this somewhere only once */ - if (one_time == 0) { + if (one_time == 0U) { sys_dlist_init(&thread_list); - one_time = 1; + one_time = 1U; } sys_dlist_append(&thread_list, &tid->node); @@ -363,7 +363,7 @@ uint32_t osThreadGetStackSpace(osThreadId_t thread_id) { struct cv2_thread *tid = (struct cv2_thread *)thread_id; u32_t size = tid->z_thread.stack_info.size; - u32_t unused = 0; + u32_t unused = 0U; __ASSERT(tid, ""); __ASSERT(is_cmsis_rtos_v2_thread(tid), ""); @@ -543,7 +543,7 @@ osStatus_t osThreadTerminate(osThreadId_t thread_id) uint32_t osThreadGetCount(void) { struct k_thread *thread; - u32_t count = 0; + u32_t count = 0U; __ASSERT(!k_is_in_isr(), ""); for (thread = _kernel.threads; thread; thread = thread->next_thread) { @@ -561,7 +561,7 @@ uint32_t osThreadGetCount(void) uint32_t osThreadEnumerate(osThreadId_t *thread_array, uint32_t array_items) { struct k_thread *thread; - u32_t count = 0; + u32_t count = 0U; osThreadId_t tid; __ASSERT(!k_is_in_isr(), ""); diff --git a/lib/cmsis_rtos_v2/thread_flags.c b/lib/cmsis_rtos_v2/thread_flags.c index a33d1361132..d7f769391d0 100644 --- a/lib/cmsis_rtos_v2/thread_flags.c +++ b/lib/cmsis_rtos_v2/thread_flags.c @@ -132,11 +132,11 @@ uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout) __ASSERT(tid->poll_event.state == K_POLL_STATE_SIGNALED, "event state not signalled!"); - __ASSERT(tid->poll_event.signal->signaled == 1, + __ASSERT(tid->poll_event.signal->signaled == 1U, "event signaled is not 1"); /* Reset the states to facilitate the next trigger */ - tid->poll_event.signal->signaled = 0; + tid->poll_event.signal->signaled = 0U; tid->poll_event.state = K_POLL_STATE_NOT_READY; if (options & osFlagsWaitAll) { @@ -162,7 +162,7 @@ uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout) if (timeout_ms > time_delta_ms) { timeout_ms -= time_delta_ms; } else { - timeout_ms = 0; + timeout_ms = 0U; } } else { break; diff --git a/lib/gui/lvgl/lvgl_color_1.c b/lib/gui/lvgl/lvgl_color_1.c index 6b94db7cfeb..22cbdfd50b8 100644 --- a/lib/gui/lvgl/lvgl_color_1.c +++ b/lib/gui/lvgl/lvgl_color_1.c @@ -20,7 +20,7 @@ static void zephyr_disp_flush(s32_t x1, s32_t y1, s32_t x2, s32_t y2, display_get_capabilities(lvgl_display_dev, &cap); - desc.buf_size = (w * h)/8; + desc.buf_size = (w * h)/8U; desc.width = w; desc.pitch = w; desc.height = h; diff --git a/lib/gui/lvgl/lvgl_fs.c b/lib/gui/lvgl/lvgl_fs.c index a4edb972895..0d96c5b9c41 100644 --- a/lib/gui/lvgl/lvgl_fs.c +++ b/lib/gui/lvgl/lvgl_fs.c @@ -91,7 +91,7 @@ static lv_fs_res_t lvgl_fs_read(void *file, void *buf, u32_t btr, } err = 0; } else if (br != NULL) { - *br = 0; + *br = 0U; } return errno_to_lv_fs_res(err); } @@ -109,7 +109,7 @@ static lv_fs_res_t lvgl_fs_write(void *file, const void *buf, u32_t btw, err = 0; } else if (err < 0) { if (bw != NULL) { - *bw = 0; + *bw = 0U; } } else { if (bw != NULL) { @@ -159,7 +159,7 @@ static lv_fs_res_t lvgl_fs_size(void *file, u32_t *fsize) err = fs_seek((struct fs_file_t *) file, 0, FS_SEEK_END); if (err != 0) { - *fsize = 0; + *fsize = 0U; return errno_to_lv_fs_res(err); } diff --git a/lib/libc/minimal/source/stdout/prf.c b/lib/libc/minimal/source/stdout/prf.c index 157634b315b..95ae07d92ab 100644 --- a/lib/libc/minimal/source/stdout/prf.c +++ b/lib/libc/minimal/source/stdout/prf.c @@ -160,12 +160,12 @@ static void _ldiv5(uint64_t *v) /* Usage in this file wants rounded behavior, not truncation. So add * two to get the threshold right. */ - rem += 2; + rem += 2U; for (i = 0U; i < 3; i++) { hi = rem >> shifts[i]; - q = (uint64_t)(hi / 5) << shifts[i]; - rem -= q * 5; + q = (uint64_t)(hi / 5U) << shifts[i]; + rem -= q * 5U; quot += q; } @@ -178,7 +178,7 @@ static char _get_digit(uint64_t *fr, int *digit_count) if (*digit_count > 0) { *digit_count -= 1; - *fr = *fr * 10; + *fr = *fr * 10U; rval = ((*fr >> 60) & 0xF) + '0'; *fr &= 0x0FFFFFFFFFFFFFFFull; } else { @@ -287,7 +287,7 @@ static int _to_float(char *buf, uint64_t double_temp, int c, _rlrshift(&fract); exp++; } - fract *= 5; + fract *= 5U; exp++; decexp--; diff --git a/lib/libc/minimal/source/string/string.c b/lib/libc/minimal/source/string/string.c index 8685d4a3e16..a9742276760 100644 --- a/lib/libc/minimal/source/string/string.c +++ b/lib/libc/minimal/source/string/string.c @@ -240,7 +240,7 @@ void *memcpy(void *_MLIBC_RESTRICT d, const void *_MLIBC_RESTRICT s, size_t n) unsigned char *d_byte = (unsigned char *)d; const unsigned char *s_byte = (const unsigned char *)s; - if ((((unsigned int)d ^ (unsigned int)s_byte) & 0x3) == 0) { + if ((((unsigned int)d ^ (unsigned int)s_byte) & 0x3) == 0U) { /* do byte-sized copying until word-aligned or finished */ diff --git a/lib/os/base64.c b/lib/os/base64.c index b4a6116f38c..fda63dc6f6d 100644 --- a/lib/os/base64.c +++ b/lib/os/base64.c @@ -151,7 +151,7 @@ int base64_decode(u8_t *dst, size_t dlen, size_t *olen, const u8_t *src, } /* Space inside a line is an error */ - if (x != 0) { + if (x != 0U) { return -EINVAL; } @@ -159,11 +159,11 @@ int base64_decode(u8_t *dst, size_t dlen, size_t *olen, const u8_t *src, return -EINVAL; } - if (src[i] > 127 || base64_dec_map[src[i]] == 127) { + if (src[i] > 127 || base64_dec_map[src[i]] == 127U) { return -EINVAL; } - if (base64_dec_map[src[i]] < 64 && j != 0) { + if (base64_dec_map[src[i]] < 64 && j != 0U) { return -EINVAL; } @@ -193,7 +193,7 @@ int base64_decode(u8_t *dst, size_t dlen, size_t *olen, const u8_t *src, continue; } - j -= (base64_dec_map[*src] == 64); + j -= (base64_dec_map[*src] == 64U); x = (x << 6) | (base64_dec_map[*src] & 0x3F); if (++n == 4) { diff --git a/lib/posix/mqueue.c b/lib/posix/mqueue.c index da67991e74a..155077194d4 100644 --- a/lib/posix/mqueue.c +++ b/lib/posix/mqueue.c @@ -375,7 +375,7 @@ static s32_t send_message(mqueue_desc *mqd, const char *msg_ptr, size_t msg_len, return ret; } - if ((mqd->flags & O_NONBLOCK) != 0) { + if ((mqd->flags & O_NONBLOCK) != 0U) { timeout = K_NO_WAIT; } @@ -407,7 +407,7 @@ static s32_t receive_message(mqueue_desc *mqd, char *msg_ptr, size_t msg_len, return ret; } - if ((mqd->flags & O_NONBLOCK) != 0) { + if ((mqd->flags & O_NONBLOCK) != 0U) { timeout = K_NO_WAIT; } diff --git a/lib/posix/pthread.c b/lib/posix/pthread.c index 7a5f4ce2d0e..f1412d3895d 100644 --- a/lib/posix/pthread.c +++ b/lib/posix/pthread.c @@ -86,7 +86,7 @@ int pthread_attr_setschedparam(pthread_attr_t *attr, { int priority = schedparam->sched_priority; - if ((attr == NULL) || (attr->initialized == 0) || + if ((attr == NULL) || (attr->initialized == 0U) || (is_posix_prio_valid(priority, attr->schedpolicy) == false)) { return EINVAL; } @@ -140,7 +140,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, * pointer and stack size. So even though POSIX 1003.1 spec accepts * attrib as NULL but zephyr needs it initialized with valid stack. */ - if ((attr == NULL) || (attr->initialized == 0) + if ((attr == NULL) || (attr->initialized == 0U) || (attr->stack == NULL) || (attr->stacksize == 0)) { return EINVAL; } @@ -461,7 +461,7 @@ int pthread_detach(pthread_t thread) */ int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) { - if ((attr == NULL) || (attr->initialized == 0)) { + if ((attr == NULL) || (attr->initialized == 0U)) { return EINVAL; } @@ -476,7 +476,7 @@ int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) */ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) { - if ((attr == NULL) || (attr->initialized == 0) || + if ((attr == NULL) || (attr->initialized == 0U) || (detachstate != PTHREAD_CREATE_DETACHED && detachstate != PTHREAD_CREATE_JOINABLE)) { return EINVAL; @@ -494,7 +494,7 @@ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) */ int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) { - if ((attr == NULL) || (attr->initialized == 0)) { + if ((attr == NULL) || (attr->initialized == 0U)) { return EINVAL; } @@ -510,7 +510,7 @@ int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) */ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) { - if ((attr == NULL) || (attr->initialized == 0) || + if ((attr == NULL) || (attr->initialized == 0U) || (policy != SCHED_RR && policy != SCHED_FIFO)) { return EINVAL; } @@ -526,7 +526,7 @@ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) */ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) { - if ((attr == NULL) || (attr->initialized == 0)) { + if ((attr == NULL) || (attr->initialized == 0U)) { return EINVAL; } @@ -543,7 +543,7 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize) { - if ((attr == NULL) || (attr->initialized == 0)) { + if ((attr == NULL) || (attr->initialized == 0U)) { return EINVAL; } @@ -560,7 +560,7 @@ int pthread_attr_getstack(const pthread_attr_t *attr, int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *schedparam) { - if ((attr == NULL) || (attr->initialized == 0)) { + if ((attr == NULL) || (attr->initialized == 0U)) { return EINVAL; } @@ -575,7 +575,7 @@ int pthread_attr_getschedparam(const pthread_attr_t *attr, */ int pthread_attr_destroy(pthread_attr_t *attr) { - if ((attr != NULL) && (attr->initialized != 0)) { + if ((attr != NULL) && (attr->initialized != 0U)) { attr->initialized = false; return 0; } diff --git a/lib/posix/pthread_cond.c b/lib/posix/pthread_cond.c index 320d5173653..7bde01ee957 100644 --- a/lib/posix/pthread_cond.c +++ b/lib/posix/pthread_cond.c @@ -11,11 +11,11 @@ static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut, int timeout) { - __ASSERT(mut->lock_count == 1, ""); + __ASSERT(mut->lock_count == 1U, ""); int ret, key = irq_lock(); - mut->lock_count = 0; + mut->lock_count = 0U; mut->owner = NULL; _ready_one_thread(&mut->wait_q); ret = z_pend_curr_irqlock(key, &cv->wait_q, timeout); diff --git a/lib/posix/pthread_mutex.c b/lib/posix/pthread_mutex.c index c7597e448a5..414ad349acc 100644 --- a/lib/posix/pthread_mutex.c +++ b/lib/posix/pthread_mutex.c @@ -22,7 +22,7 @@ static int acquire_mutex(pthread_mutex_t *m, int timeout) { int rc = 0, key = irq_lock(); - if (m->lock_count == 0 && m->owner == NULL) { + if (m->lock_count == 0U && m->owner == NULL) { m->lock_count++; m->owner = pthread_self(); @@ -89,7 +89,7 @@ int pthread_mutex_init(pthread_mutex_t *m, const pthread_mutexattr_t *mattr; m->owner = NULL; - m->lock_count = 0; + m->lock_count = 0U; mattr = (attr == NULL) ? &def_attr : attr; @@ -127,14 +127,14 @@ int pthread_mutex_unlock(pthread_mutex_t *m) return EPERM; } - if (m->lock_count == 0) { + if (m->lock_count == 0U) { irq_unlock(key); return EINVAL; } m->lock_count--; - if (m->lock_count == 0) { + if (m->lock_count == 0U) { thread = z_unpend_first_thread(&m->wait_q); if (thread) { m->owner = (pthread_t)thread; diff --git a/lib/posix/pthread_rwlock.c b/lib/posix/pthread_rwlock.c index fcf5b982d9e..9639444d765 100644 --- a/lib/posix/pthread_rwlock.c +++ b/lib/posix/pthread_rwlock.c @@ -95,7 +95,7 @@ int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, timeout = (s32_t) timespec_to_timeoutms(abstime); - if (read_lock_acquire(rwlock, timeout) != 0) { + if (read_lock_acquire(rwlock, timeout) != 0U) { ret = ETIMEDOUT; } @@ -157,7 +157,7 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, timeout = (s32_t) timespec_to_timeoutms(abstime); - if (write_lock_acquire(rwlock, timeout) != 0) { + if (write_lock_acquire(rwlock, timeout) != 0U) { ret = ETIMEDOUT; } diff --git a/lib/posix/timer.c b/lib/posix/timer.c index beefd76ea72..e0a52b870ad 100644 --- a/lib/posix/timer.c +++ b/lib/posix/timer.c @@ -32,7 +32,7 @@ static void zephyr_timer_wrapper(struct k_timer *ztimer) timer = (struct timer_obj *)ztimer; - if (timer->reload == 0) { + if (timer->reload == 0U) { timer->status = NOT_ACTIVE; } diff --git a/samples/application_development/code_relocation/src/main.c b/samples/application_development/code_relocation/src/main.c index 5060b0f7e37..ec0dfeee74c 100644 --- a/samples/application_development/code_relocation/src/main.c +++ b/samples/application_development/code_relocation/src/main.c @@ -24,7 +24,7 @@ void disable_mpu_rasr_xn(void) /* Kept the max index as 8(irrespective of soc) because the sram * would most likely be set at index 2. */ - for (index = 0; index < 8; index++) { + for (index = 0U; index < 8; index++) { MPU->RNR = index; if (MPU->RASR & MPU_RASR_XN_Msk) { MPU->RASR ^= MPU_RASR_XN_Msk; diff --git a/samples/basic/blink_led/src/main.c b/samples/basic/blink_led/src/main.c index 26426dbd0c5..80b7110b876 100644 --- a/samples/basic/blink_led/src/main.c +++ b/samples/basic/blink_led/src/main.c @@ -45,7 +45,7 @@ #endif /* in micro second */ -#define MIN_PERIOD (USEC_PER_SEC / 64) +#define MIN_PERIOD (USEC_PER_SEC / 64U) /* in micro second */ #define MAX_PERIOD USEC_PER_SEC @@ -66,20 +66,20 @@ void main(void) while (1) { if (pwm_pin_set_usec(pwm_dev, PWM_CHANNEL, - period, period / 2)) { + period, period / 2U)) { printk("pwm pin set fails\n"); return; } if (dir) { - period *= 2; + period *= 2U; if (period > MAX_PERIOD) { dir = 0U; period = MAX_PERIOD; } } else { - period /= 2; + period /= 2U; if (period < MIN_PERIOD) { dir = 1U; @@ -87,6 +87,6 @@ void main(void) } } - k_sleep(MSEC_PER_SEC * 4); + k_sleep(MSEC_PER_SEC * 4U); } } diff --git a/samples/basic/fade_led/src/main.c b/samples/basic/fade_led/src/main.c index 0a0575ce346..e64ddd311a8 100644 --- a/samples/basic/fade_led/src/main.c +++ b/samples/basic/fade_led/src/main.c @@ -50,7 +50,7 @@ * 50 is flicker fusion threshold. Modulated light will be perceived * as steady by our eyes when blinking rate is at least 50. */ -#define PERIOD (USEC_PER_SEC / 50) +#define PERIOD (USEC_PER_SEC / 50U) /* in micro second */ #define FADESTEP 2000 diff --git a/samples/basic/rgb_led/src/main.c b/samples/basic/rgb_led/src/main.c index fc5f04380e9..d5256c5e490 100644 --- a/samples/basic/rgb_led/src/main.c +++ b/samples/basic/rgb_led/src/main.c @@ -38,7 +38,7 @@ * 50 is flicker fusion threshold. Modulated light will be perceived * as steady by our eyes when blinking rate is at least 50. */ -#define PERIOD (USEC_PER_SEC / 50) +#define PERIOD (USEC_PER_SEC / 50U) /* in micro second */ #define STEPSIZE 2000 diff --git a/samples/basic/servo_motor/src/main.c b/samples/basic/servo_motor/src/main.c index 17c2221655a..3139334cdaf 100644 --- a/samples/basic/servo_motor/src/main.c +++ b/samples/basic/servo_motor/src/main.c @@ -27,7 +27,7 @@ * Unlike pulse width, period is not a critical parameter for * motor control. 20ms is commonly used. */ -#define PERIOD (USEC_PER_SEC / 50) +#define PERIOD (USEC_PER_SEC / 50U) /* all in micro second */ #define STEPSIZE 100 diff --git a/samples/bluetooth/central_hr/src/main.c b/samples/bluetooth/central_hr/src/main.c index 78eff8451de..4f55158ac2f 100644 --- a/samples/bluetooth/central_hr/src/main.c +++ b/samples/bluetooth/central_hr/src/main.c @@ -31,7 +31,7 @@ static u8_t notify_func(struct bt_conn *conn, { if (!data) { printk("[UNSUBSCRIBED]\n"); - params->value_handle = 0; + params->value_handle = 0U; return BT_GATT_ITER_STOP; } @@ -134,7 +134,7 @@ static bool eir_found(struct bt_data *data, void *user_data) switch (data->type) { case BT_DATA_UUID16_SOME: case BT_DATA_UUID16_ALL: - if (data->data_len % sizeof(u16_t) != 0) { + if (data->data_len % sizeof(u16_t) != 0U) { printk("AD malformed\n"); return true; } diff --git a/samples/bluetooth/eddystone/src/main.c b/samples/bluetooth/eddystone/src/main.c index 1cc6a580a4f..2358e780c82 100644 --- a/samples/bluetooth/eddystone/src/main.c +++ b/samples/bluetooth/eddystone/src/main.c @@ -322,7 +322,7 @@ static ssize_t write_lock(struct bt_conn *conn, } /* Write 1 byte to lock or 17 bytes to transition to a new lock state */ - if (len != 1) { + if (len != 1U) { /* TODO: Allow setting new lock code, using AES-128-ECB to * decrypt with the existing lock code and set the unencrypted * value as the new code. diff --git a/samples/bluetooth/gatt/hrs.c b/samples/bluetooth/gatt/hrs.c index 23ff9155e0f..3e79ac1b46a 100644 --- a/samples/bluetooth/gatt/hrs.c +++ b/samples/bluetooth/gatt/hrs.c @@ -71,7 +71,7 @@ void hrs_notify(void) } heartrate++; - if (heartrate == 160) { + if (heartrate == 160U) { heartrate = 90U; } diff --git a/samples/bluetooth/hci_spi/src/main.c b/samples/bluetooth/hci_spi/src/main.c index 3db72fcc6e4..aa067c6bc73 100644 --- a/samples/bluetooth/hci_spi/src/main.c +++ b/samples/bluetooth/hci_spi/src/main.c @@ -318,7 +318,7 @@ void main(void) bt_buf_set_type(buf, BT_BUF_EVT); evt_hdr = net_buf_add(buf, sizeof(*evt_hdr)); evt_hdr->evt = BT_HCI_EVT_VENDOR; - evt_hdr->len = 2; + evt_hdr->len = 2U; net_buf_add_le16(buf, EVT_BLUE_INITIALIZED); err = spi_send(buf); if (err) { diff --git a/samples/bluetooth/mesh_demo/src/microbit.c b/samples/bluetooth/mesh_demo/src/microbit.c index fe4872f428b..00d790b96dd 100644 --- a/samples/bluetooth/mesh_demo/src/microbit.c +++ b/samples/bluetooth/mesh_demo/src/microbit.c @@ -108,7 +108,7 @@ void board_play_tune(const char *str) } while (isdigit((unsigned char)*str)) { - duration *= 10; + duration *= 10U; duration += *str - '0'; str++; } @@ -126,7 +126,7 @@ void board_play_tune(const char *str) } if (period) { - pwm_pin_set_usec(pwm, BUZZER_PIN, period, period / 2); + pwm_pin_set_usec(pwm, BUZZER_PIN, period, period / 2U); } k_sleep(duration); diff --git a/samples/bluetooth/peripheral/src/main.c b/samples/bluetooth/peripheral/src/main.c index 1c3aef7054e..fa86abdf256 100644 --- a/samples/bluetooth/peripheral/src/main.c +++ b/samples/bluetooth/peripheral/src/main.c @@ -78,7 +78,7 @@ static void vnd_ccc_cfg_changed(const struct bt_gatt_attr *attr, u16_t value) static void indicate_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr, u8_t err) { - printk("Indication %s\n", err != 0 ? "fail" : "success"); + printk("Indication %s\n", err != 0U ? "fail" : "success"); indicating = 0U; } diff --git a/samples/bluetooth/peripheral_csc/src/main.c b/samples/bluetooth/peripheral_csc/src/main.c index 34b2e13f716..74c5b213a34 100644 --- a/samples/bluetooth/peripheral_csc/src/main.c +++ b/samples/bluetooth/peripheral_csc/src/main.c @@ -312,13 +312,13 @@ static void csc_simulation(void) /* Measurements don't have to be updated every second */ if (!(i % 2)) { lwet += 1050 + rand % 50; - cwr += 2; + cwr += 2U; nfy_wheel = true; } if (!(i % 3)) { lcet += 1000 + rand % 50; - ccr += 1; + ccr += 1U; nfy_crank = true; } diff --git a/samples/boards/96b_argonkey/microphone/src/main.c b/samples/boards/96b_argonkey/microphone/src/main.c index 6994484c2b9..3ede087908d 100644 --- a/samples/boards/96b_argonkey/microphone/src/main.c +++ b/samples/boards/96b_argonkey/microphone/src/main.c @@ -144,7 +144,7 @@ void main(void) signal_sampling_started(); /* Acquire microphone audio */ - for (ms = 0; ms < NUM_MS; ms++) { + for (ms = 0U; ms < NUM_MS; ms++) { ret = dmic_read(mic_dev, 0, &rx_block[ms], &rx_size, 2000); if (ret < 0) { printk("microphone audio read error\n"); diff --git a/samples/boards/altera_max10/pio/src/main.c b/samples/boards/altera_max10/pio/src/main.c index d834a9cae76..563b481ac3b 100644 --- a/samples/boards/altera_max10/pio/src/main.c +++ b/samples/boards/altera_max10/pio/src/main.c @@ -59,7 +59,7 @@ void main(void) if (ret) { printk("Error set GPIO port\n"); } - k_sleep(MSEC_PER_SEC * 5); + k_sleep(MSEC_PER_SEC * 5U); for (i = 0; i < LED_PINS_WIRED; i++) { printk("Turn On LED[%d]\n", i); @@ -68,7 +68,7 @@ void main(void) printk("Error writing led pin\n"); } - k_sleep(MSEC_PER_SEC * 5); + k_sleep(MSEC_PER_SEC * 5U); ret = gpio_pin_write(gpio_dev, i, 1); if (ret) { printk("Error writing led pin\n"); diff --git a/samples/boards/bbc_microbit/pong/src/ble.c b/samples/boards/bbc_microbit/pong/src/ble.c index cd4697bf4f9..bd20522a749 100644 --- a/samples/boards/bbc_microbit/pong/src/ble.c +++ b/samples/boards/bbc_microbit/pong/src/ble.c @@ -323,12 +323,12 @@ void ble_cancel_connect(void) static bool pong_uuid_match(const u8_t *data, u8_t len) { - while (len >= 16) { + while (len >= 16U) { if (!memcmp(data, pong_svc_uuid.val, 16)) { return true; } - len -= 16; + len -= 16U; data += 16; } @@ -365,7 +365,7 @@ static void device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type, u8_t type; /* Check for early termination */ - if (len == 0) { + if (len == 0U) { return; } diff --git a/samples/boards/bbc_microbit/sound/src/main.c b/samples/boards/bbc_microbit/sound/src/main.c index f975571b300..d248527a475 100644 --- a/samples/boards/bbc_microbit/sound/src/main.c +++ b/samples/boards/bbc_microbit/sound/src/main.c @@ -34,7 +34,7 @@ static void beep(struct k_work *work) /* The "period / 2" pulse duration gives 50% duty cycle, which * should result in the maximum sound volume. */ - pwm_pin_set_usec(pwm, BUZZER_PIN, period, period / 2); + pwm_pin_set_usec(pwm, BUZZER_PIN, period, period / 2U); k_sleep(BEEP_DURATION); /* Disable the PWM */ @@ -60,12 +60,12 @@ static void button_pressed(struct device *dev, struct gpio_callback *cb, if (pins & BIT(SW0_GPIO_PIN)) { printk("A pressed\n"); if (period < PERIOD_MAX) { - period += 50; + period += 50U; } } else { printk("B pressed\n"); if (period > PERIOD_MIN) { - period -= 50; + period -= 50U; } } diff --git a/samples/boards/nrf52/mesh/onoff-app/src/main.c b/samples/boards/nrf52/mesh/onoff-app/src/main.c index bfde1677596..2bbbb8a56d8 100644 --- a/samples/boards/nrf52/mesh/onoff-app/src/main.c +++ b/samples/boards/nrf52/mesh/onoff-app/src/main.c @@ -445,7 +445,7 @@ static void button_pressed(struct device *dev, struct gpio_callback *cb, return; } - if (button_press_cnt == 0) { + if (button_press_cnt == 0U) { k_timer_start(&sw.button_timer, K_SECONDS(1), 0); } @@ -468,7 +468,7 @@ static void button_cnt_timer(struct k_timer *work) { struct sw *button_sw = CONTAINER_OF(work, struct sw, button_timer); - button_sw->onoff_state = button_press_cnt == 1 ? 1 : 0; + button_sw->onoff_state = button_press_cnt == 1U ? 1 : 0; printk("button_press_cnt 0x%02x onoff_state 0x%02x\n", button_press_cnt, button_sw->onoff_state); button_press_cnt = 0U; diff --git a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/main.c b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/main.c index a4f6e2c886d..aa258014a85 100644 --- a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/main.c +++ b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/main.c @@ -156,7 +156,7 @@ void update_light_state(void) static void short_time_multireset_bt_mesh_unprovisioning(void) { - if (reset_counter >= 4) { + if (reset_counter >= 4U) { reset_counter = 0U; printk("BT Mesh reset\n"); bt_mesh_reset(); diff --git a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c index 20d69ba82db..577d241084e 100644 --- a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c +++ b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c @@ -206,7 +206,7 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->onoff = state->target_onoff; } @@ -274,7 +274,7 @@ static void gen_onoff_set(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->onoff = state->target_onoff; } @@ -292,7 +292,7 @@ static void gen_onoff_status(struct bt_mesh_model *model, printk("Acknownledgement from GEN_ONOFF_SRV\n"); printk("Present OnOff = %02x\n", net_buf_simple_pull_u8(buf)); - if (buf->len == 2) { + if (buf->len == 2U) { printk("Target OnOff = %02x\n", net_buf_simple_pull_u8(buf)); printk("Remaining Time = %02x\n", net_buf_simple_pull_u8(buf)); } @@ -399,7 +399,7 @@ static void gen_level_set_unack(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->level = state->target_level; } @@ -473,7 +473,7 @@ static void gen_level_set(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->level = state->target_level; } @@ -562,7 +562,7 @@ static void gen_delta_set_unack(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->level = state->target_level; } @@ -653,7 +653,7 @@ static void gen_delta_set(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->level = state->target_level; } @@ -789,7 +789,7 @@ static void gen_move_set_unack(struct bt_mesh_model *model, return; } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { return; } @@ -872,7 +872,7 @@ static void gen_move_set(struct bt_mesh_model *model, return; } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { return; } @@ -899,7 +899,7 @@ static void gen_level_status(struct bt_mesh_model *model, printk("Acknownledgement from GEN_LEVEL_SRV\n"); printk("Present Level = %04x\n", net_buf_simple_pull_le16(buf)); - if (buf->len == 3) { + if (buf->len == 3U) { printk("Target Level = %04x\n", net_buf_simple_pull_le16(buf)); printk("Remaining Time = %02x\n", net_buf_simple_pull_u8(buf)); } @@ -1264,7 +1264,7 @@ static void light_lightness_set_unack(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->actual = state->target_actual; } @@ -1336,7 +1336,7 @@ static void light_lightness_set(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->actual = state->target_actual; } @@ -1448,7 +1448,7 @@ static void light_lightness_linear_set_unack(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->linear = state->target_linear; } @@ -1513,7 +1513,7 @@ static void light_lightness_linear_set(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->linear = state->target_linear; } @@ -1658,7 +1658,7 @@ static bool light_lightness_range_setunack(struct bt_mesh_model *model, /* Here, Model specification is silent about tid implementation */ - if (min == 0 || max == 0) { + if (min == 0U || max == 0U) { return false; } else { if (min <= max) { @@ -1709,7 +1709,7 @@ static void light_lightness_status(struct bt_mesh_model *model, printk("Acknownledgement from LIGHT_LIGHTNESS_SRV (Actual)\n"); printk("Present Lightness = %04x\n", net_buf_simple_pull_le16(buf)); - if (buf->len == 3) { + if (buf->len == 3U) { printk("Target Lightness = %04x\n", net_buf_simple_pull_le16(buf)); printk("Remaining Time = %02x\n", net_buf_simple_pull_u8(buf)); @@ -1723,7 +1723,7 @@ static void light_lightness_linear_status(struct bt_mesh_model *model, printk("Acknownledgement from LIGHT_LIGHTNESS_SRV (Linear)\n"); printk("Present Lightness = %04x\n", net_buf_simple_pull_le16(buf)); - if (buf->len == 3) { + if (buf->len == 3U) { printk("Target Lightness = %04x\n", net_buf_simple_pull_le16(buf)); printk("Remaining Time = %02x\n", net_buf_simple_pull_u8(buf)); @@ -1883,7 +1883,7 @@ static void light_ctl_set_unack(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->lightness = state->target_lightness; state->temp = state->target_temp; state->delta_uv = state->target_delta_uv; @@ -1968,7 +1968,7 @@ static void light_ctl_set(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->lightness = state->target_lightness; state->temp = state->target_temp; state->delta_uv = state->target_delta_uv; @@ -2182,7 +2182,7 @@ static void light_ctl_status(struct bt_mesh_model *model, printk("Present CTL Temperature = %04x\n", net_buf_simple_pull_le16(buf)); - if (buf->len == 5) { + if (buf->len == 5U) { printk("Target CTL Lightness = %04x\n", net_buf_simple_pull_le16(buf)); printk("Target CTL Temperature = %04x\n", @@ -2211,7 +2211,7 @@ static void light_ctl_temp_status(struct bt_mesh_model *model, printk("Present CTL Delta UV = %04x\n", net_buf_simple_pull_le16(buf)); - if (buf->len == 5) { + if (buf->len == 5U) { printk("Target CTL Temperature = %04x\n", net_buf_simple_pull_le16(buf)); printk("Target CTL Delta UV = %04x\n", @@ -2350,7 +2350,7 @@ static void light_ctl_temp_set_unack(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->temp = state->target_temp; state->delta_uv = state->target_delta_uv; } @@ -2431,7 +2431,7 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, } /* For Instantaneous Transition */ - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->temp = state->target_temp; state->delta_uv = state->target_delta_uv; } diff --git a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c index 8df3b07d5ae..7b1c38ff4d9 100644 --- a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c +++ b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c @@ -55,7 +55,7 @@ void publish(struct k_work *work) return; } - if (button_read(button_device[0], SW0_GPIO_PIN) == 0) { + if (button_read(button_device[0], SW0_GPIO_PIN) == 0U) { #if defined(ONOFF) bt_mesh_model_msg_init(root_models[3].pub->msg, BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK); @@ -77,7 +77,7 @@ void publish(struct k_work *work) net_buf_simple_add_u8(vnd_models[0].pub->msg, tid_vnd++); err = bt_mesh_model_publish(&vnd_models[0]); #endif - } else if (button_read(button_device[1], SW1_GPIO_PIN) == 0) { + } else if (button_read(button_device[1], SW1_GPIO_PIN) == 0U) { #if defined(ONOFF) bt_mesh_model_msg_init(root_models[3].pub->msg, BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK); @@ -99,7 +99,7 @@ void publish(struct k_work *work) net_buf_simple_add_u8(vnd_models[0].pub->msg, tid_vnd++); err = bt_mesh_model_publish(&vnd_models[0]); #endif - } else if (button_read(button_device[2], SW2_GPIO_PIN) == 0) { + } else if (button_read(button_device[2], SW2_GPIO_PIN) == 0U) { #if defined(GENERIC_LEVEL) bt_mesh_model_msg_init(root_models[5].pub->msg, BT_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK); @@ -169,7 +169,7 @@ void publish(struct k_work *work) net_buf_simple_add_u8(root_models[16].pub->msg, tid_level++); err = bt_mesh_model_publish(&root_models[16]); #endif - } else if (button_read(button_device[3], SW3_GPIO_PIN) == 0) { + } else if (button_read(button_device[3], SW3_GPIO_PIN) == 0U) { #if defined(GENERIC_LEVEL) bt_mesh_model_msg_init(root_models[5].pub->msg, BT_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK); diff --git a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/state_binding.c b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/state_binding.c index 9098c47ce63..75bb1af0786 100644 --- a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/state_binding.c +++ b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/state_binding.c @@ -108,7 +108,7 @@ static s16_t light_ctl_temp_to_level(u16_t temp) /* Mesh Model Specification 6.1.3.1.1 2nd formula start */ - tmp = (temp - light_ctl_srv_user_data.temp_range_min) * 65535; + tmp = (temp - light_ctl_srv_user_data.temp_range_min) * 65535U; tmp = tmp / (light_ctl_srv_user_data.temp_range_max - light_ctl_srv_user_data.temp_range_min); @@ -137,7 +137,7 @@ static u16_t level_to_light_ctl_temp(s16_t level) void readjust_lightness(void) { - if (lightness != 0) { + if (lightness != 0U) { light_lightness_srv_user_data.last = lightness; } @@ -190,7 +190,7 @@ void state_binding(u8_t light, u8_t temp) if (gen_onoff_srv_root_user_data.onoff == STATE_OFF) { lightness = 0U; } else if (gen_onoff_srv_root_user_data.onoff == STATE_ON) { - if (light_lightness_srv_user_data.def == 0) { + if (light_lightness_srv_user_data.def == 0U) { lightness = light_lightness_srv_user_data.last; } else { lightness = light_lightness_srv_user_data.def; @@ -230,10 +230,10 @@ void calculate_lightness_target_values(u8_t type) switch (type) { case ONOFF: - if (gen_onoff_srv_root_user_data.target_onoff == 0) { + if (gen_onoff_srv_root_user_data.target_onoff == 0U) { tmp = 0U; } else { - if (light_lightness_srv_user_data.def == 0) { + if (light_lightness_srv_user_data.def == 0U) { tmp = light_lightness_srv_user_data.last; } else { tmp = light_lightness_srv_user_data.def; diff --git a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/transition.c b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/transition.c index 1f647dd0356..d5218428060 100644 --- a/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/transition.c +++ b/samples/boards/nrf52/mesh/onoff_level_lighting_vnd_app/src/mesh/transition.c @@ -90,22 +90,22 @@ static bool tt_values_calculator(struct transition *transition) resolution = (transition->tt >> 6); steps_multiplier = (transition->tt & 0x3F); - if (steps_multiplier == 0) { + if (steps_multiplier == 0U) { return false; } switch (resolution) { case 0: /* 100ms */ - transition->total_duration = steps_multiplier * 100; + transition->total_duration = steps_multiplier * 100U; break; case 1: /* 1 second */ - transition->total_duration = steps_multiplier * 1000; + transition->total_duration = steps_multiplier * 1000U; break; case 2: /* 10 seconds */ - transition->total_duration = steps_multiplier * 10000; + transition->total_duration = steps_multiplier * 10000U; break; case 3: /* 10 minutes */ - transition->total_duration = steps_multiplier * 600000; + transition->total_duration = steps_multiplier * 600000U; break; } @@ -258,7 +258,7 @@ static void onoff_work_handler(struct k_work *work) if (state->transition->just_started) { state->transition->just_started = false; - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state_binding(ONOFF, IGNORE_TEMP); update_light_state(); @@ -274,7 +274,7 @@ static void onoff_work_handler(struct k_work *work) return; } - if (state->transition->counter != 0) { + if (state->transition->counter != 0U) { state->transition->counter--; lightness -= state->tt_delta; @@ -283,7 +283,7 @@ static void onoff_work_handler(struct k_work *work) update_light_state(); } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->onoff = state->target_onoff; lightness = target_lightness; @@ -316,7 +316,7 @@ static void level_lightness_work_handler(struct k_work *work) if (state->transition->just_started) { state->transition->just_started = false; - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state_binding(level, IGNORE_TEMP); update_light_state(); @@ -328,7 +328,7 @@ static void level_lightness_work_handler(struct k_work *work) return; } - if (state->transition->counter != 0) { + if (state->transition->counter != 0U) { state->transition->counter--; state->level -= state->tt_delta; @@ -337,7 +337,7 @@ static void level_lightness_work_handler(struct k_work *work) update_light_state(); } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->level = state->target_level; state_binding(level, IGNORE_TEMP); @@ -365,7 +365,7 @@ static void level_temp_work_handler(struct k_work *work) if (state->transition->just_started) { state->transition->just_started = false; - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state_binding(IGNORE, LEVEL_TEMP); update_light_state(); @@ -377,7 +377,7 @@ static void level_temp_work_handler(struct k_work *work) return; } - if (state->transition->counter != 0) { + if (state->transition->counter != 0U) { state->transition->counter--; state->level -= state->tt_delta; @@ -386,7 +386,7 @@ static void level_temp_work_handler(struct k_work *work) update_light_state(); } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->level = state->target_level; state_binding(IGNORE, LEVEL_TEMP); @@ -403,7 +403,7 @@ static void light_lightness_actual_work_handler(struct k_work *work) if (state->transition->just_started) { state->transition->just_started = false; - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state_binding(ACTUAL, IGNORE_TEMP); update_light_state(); @@ -415,7 +415,7 @@ static void light_lightness_actual_work_handler(struct k_work *work) return; } - if (state->transition->counter != 0) { + if (state->transition->counter != 0U) { state->transition->counter--; state->actual -= state->tt_delta_actual; @@ -424,7 +424,7 @@ static void light_lightness_actual_work_handler(struct k_work *work) update_light_state(); } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->actual = state->target_actual; state_binding(ACTUAL, IGNORE_TEMP); @@ -441,7 +441,7 @@ static void light_lightness_linear_work_handler(struct k_work *work) if (state->transition->just_started) { state->transition->just_started = false; - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state_binding(LINEAR, IGNORE_TEMP); update_light_state(); @@ -453,7 +453,7 @@ static void light_lightness_linear_work_handler(struct k_work *work) return; } - if (state->transition->counter != 0) { + if (state->transition->counter != 0U) { state->transition->counter--; state->linear -= state->tt_delta_linear; @@ -462,7 +462,7 @@ static void light_lightness_linear_work_handler(struct k_work *work) update_light_state(); } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->linear = state->target_linear; state_binding(LINEAR, IGNORE_TEMP); @@ -479,7 +479,7 @@ static void light_ctl_work_handler(struct k_work *work) if (state->transition->just_started) { state->transition->just_started = false; - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state_binding(CTL, CTL_TEMP); update_light_state(); @@ -491,7 +491,7 @@ static void light_ctl_work_handler(struct k_work *work) return; } - if (state->transition->counter != 0) { + if (state->transition->counter != 0U) { state->transition->counter--; /* Lightness */ @@ -507,7 +507,7 @@ static void light_ctl_work_handler(struct k_work *work) update_light_state(); } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->lightness = state->target_lightness; state->temp = state->target_temp; state->delta_uv = state->target_delta_uv; @@ -526,7 +526,7 @@ static void light_ctl_temp_work_handler(struct k_work *work) if (state->transition->just_started) { state->transition->just_started = false; - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state_binding(IGNORE, CTL_TEMP); update_light_state(); @@ -538,7 +538,7 @@ static void light_ctl_temp_work_handler(struct k_work *work) return; } - if (state->transition->counter != 0) { + if (state->transition->counter != 0U) { state->transition->counter--; /* Temperature */ @@ -551,7 +551,7 @@ static void light_ctl_temp_work_handler(struct k_work *work) update_light_state(); } - if (state->transition->counter == 0) { + if (state->transition->counter == 0U) { state->temp = state->target_temp; state->delta_uv = state->target_delta_uv; diff --git a/samples/boards/reel_board/mesh_badge/src/mesh.c b/samples/boards/reel_board/mesh_badge/src/mesh.c index 6043496719a..633183df1fa 100644 --- a/samples/boards/reel_board/mesh_badge/src/mesh.c +++ b/samples/boards/reel_board/mesh_badge/src/mesh.c @@ -377,7 +377,7 @@ static void vnd_heartbeat(struct bt_mesh_model *model, hops = init_ttl - ctx->recv_ttl + 1; printk("Heartbeat from 0x%04x over %u hop%s\n", ctx->addr, - hops, hops == 1 ? "" : "s"); + hops, hops == 1U ? "" : "s"); board_add_heartbeat(ctx->addr, hops); } diff --git a/samples/boards/reel_board/mesh_badge/src/reel_board.c b/samples/boards/reel_board/mesh_badge/src/reel_board.c index 8b469687bab..93c90968687 100644 --- a/samples/boards/reel_board/mesh_badge/src/reel_board.c +++ b/samples/boards/reel_board/mesh_badge/src/reel_board.c @@ -90,7 +90,7 @@ static size_t print_line(enum font_size font_size, int row, const char *text, line[len] = '\0'; if (center) { - pad = (fonts[font_size].columns - len) / 2; + pad = (fonts[font_size].columns - len) / 2U; } else { pad = 0; } @@ -486,7 +486,7 @@ static void button_interrupt(struct device *dev, struct gpio_callback *cb, if (uptime - press_ts < 500) { bad_count++; } else { - bad_count = 0; + bad_count = 0U; } press_ts = uptime; @@ -494,7 +494,7 @@ static void button_interrupt(struct device *dev, struct gpio_callback *cb, if (bad_count) { if (bad_count > 5) { mesh_send_baduser(); - bad_count = 0; + bad_count = 0U; } else { printk("Ignoring press\n"); } diff --git a/samples/drivers/CAN/src/main.c b/samples/drivers/CAN/src/main.c index 81d6162a9d0..86b2fc79117 100644 --- a/samples/drivers/CAN/src/main.c +++ b/samples/drivers/CAN/src/main.c @@ -56,7 +56,7 @@ void send_string(char *string, struct device *can_dev) msg.ext_id = STR_MSG_ID; msg.id_type = CAN_EXTENDED_IDENTIFIER; - msg.dlc = 0; + msg.dlc = 0U; msg.rtr = CAN_DATAFRAME; for (str_len = strlen(string); str_len; ) { @@ -78,16 +78,16 @@ void tx_thread(void *can_dev_param, void *unused2, void *unused3) msg.std_id = LED_MSG_ID; msg.id_type = CAN_STANDARD_IDENTIFIER; - msg.dlc = 1; + msg.dlc = 1U; msg.rtr = CAN_DATAFRAME; - msg.data[0] = 0; + msg.data[0] = 0U; msg_button_cnt.std_id = BUTTON_MSG_ID; msg_button_cnt.id_type = CAN_STANDARD_IDENTIFIER; - msg_button_cnt.dlc = 2; + msg_button_cnt.dlc = 2U; msg_button_cnt.rtr = CAN_DATAFRAME; - msg_button_cnt.data[0] = 0; - msg_button_cnt.data[1] = 0; + msg_button_cnt.data[0] = 0U; + msg_button_cnt.data[1] = 0U; printk("TX thread is running.\n"); while (1) { @@ -156,7 +156,7 @@ void led_thread(void *msgq, void *can_dev_param, void *gpio_dev_param) while (1) { k_msgq_get((struct k_msgq *)msgq, &msg, K_FOREVER); - if (msg.dlc != 1) { + if (msg.dlc != 1U) { continue; } diff --git a/samples/drivers/crypto/src/main.c b/samples/drivers/crypto/src/main.c index b74932875e7..922ffb233ae 100644 --- a/samples/drivers/crypto/src/main.c +++ b/samples/drivers/crypto/src/main.c @@ -88,19 +88,19 @@ int validate_hw_compatibility(struct device *dev) u32_t flags = 0U; flags = cipher_query_hwcaps(dev); - if ((flags & CAP_RAW_KEY) == 0) { + if ((flags & CAP_RAW_KEY) == 0U) { LOG_INF("Please provision the key separately " "as the module doesnt support a raw key"); return -1; } - if ((flags & CAP_SYNC_OPS) == 0) { + if ((flags & CAP_SYNC_OPS) == 0U) { LOG_ERR("The app assumes sync semantics. " "Please rewrite the app accordingly before proceeding"); return -1; } - if ((flags & CAP_SEPARATE_IO_BUFS) == 0) { + if ((flags & CAP_SEPARATE_IO_BUFS) == 0U) { LOG_ERR("The app assumes distinct IO buffers. " "Please rewrite the app accordingly before proceeding"); return -1; diff --git a/samples/drivers/current_sensing/src/main.c b/samples/drivers/current_sensing/src/main.c index 27e011ac0ae..1925e51cf0c 100644 --- a/samples/drivers/current_sensing/src/main.c +++ b/samples/drivers/current_sensing/src/main.c @@ -45,12 +45,12 @@ int read_reg16(struct device *i2c_dev, u8_t reg_addr, /* Send the address to read */ msgs[0].buf = &wr_addr; - msgs[0].len = 1; + msgs[0].len = 1U; msgs[0].flags = I2C_MSG_WRITE; /* Read from device. RESTART as neededm and STOP after this. */ msgs[1].buf = data; - msgs[1].len = 2; + msgs[1].len = 2U; msgs[1].flags = I2C_MSG_READ | I2C_MSG_RESTART | I2C_MSG_STOP; return i2c_transfer(i2c_dev, &msgs[0], 2, I2C_SLV_ADDR); @@ -69,12 +69,12 @@ int write_reg16(struct device *i2c_dev, u8_t reg_addr, /* Send the address to read */ msgs[0].buf = &wr_addr; - msgs[0].len = 1; + msgs[0].len = 1U; msgs[0].flags = I2C_MSG_WRITE; /* Read from device. RESTART as neededm and STOP after this. */ msgs[1].buf = data; - msgs[1].len = 2; + msgs[1].len = 2U; msgs[1].flags = I2C_MSG_WRITE | I2C_MSG_STOP; return i2c_transfer(i2c_dev, &msgs[0], 2, I2C_SLV_ADDR); @@ -106,13 +106,13 @@ void main(void) read_reg16(i2c_dev, 0x02, data); bus_volt = (data[0] << 8) | data[1]; bus_volt >>= 3; /* 3 LSBs are not data */ - bus_volt *= 4; /* each LSB is 4 mV */ + bus_volt *= 4U; /* each LSB is 4 mV */ printk("Bus Voltage: %d mV\n", bus_volt); /* Read shunt voltage */ read_reg16(i2c_dev, 0x01, data); shunt_volt = (data[0] << 8) | data[1]; - shunt_volt *= 10; /* to uV since each LSB is 0.01 mV */ + shunt_volt *= 10U; /* to uV since each LSB is 0.01 mV */ printk("Shunt Voltage: %d uV\n", shunt_volt); /* Read current */ diff --git a/samples/drivers/entropy/src/main.c b/samples/drivers/entropy/src/main.c index 460f2abf844..4e4c6a460c8 100644 --- a/samples/drivers/entropy/src/main.c +++ b/samples/drivers/entropy/src/main.c @@ -40,7 +40,7 @@ void main(void) break; } - if (buffer[BUFFER_LENGTH-1] != 0) { + if (buffer[BUFFER_LENGTH-1] != 0U) { printf("entropy_get_entropy buffer overflow\n"); } diff --git a/samples/drivers/i2c_fujitsu_fram/src/main.c b/samples/drivers/i2c_fujitsu_fram/src/main.c index 8cf5ba8a245..cafd90d64b7 100644 --- a/samples/drivers/i2c_fujitsu_fram/src/main.c +++ b/samples/drivers/i2c_fujitsu_fram/src/main.c @@ -36,7 +36,7 @@ static int write_bytes(struct device *i2c_dev, u16_t addr, /* Send the address to write to */ msgs[0].buf = wr_addr; - msgs[0].len = 2; + msgs[0].len = 2U; msgs[0].flags = I2C_MSG_WRITE; /* Data to be written, and STOP after this. */ @@ -63,7 +63,7 @@ static int read_bytes(struct device *i2c_dev, u16_t addr, /* Send the address to read from */ msgs[0].buf = wr_addr; - msgs[0].len = 2; + msgs[0].len = 2U; msgs[0].flags = I2C_MSG_WRITE; /* Read from device. STOP after this. */ diff --git a/samples/drivers/i2c_scanner/src/main.c b/samples/drivers/i2c_scanner/src/main.c index 2d4b9b0d602..68c6740ee3f 100644 --- a/samples/drivers/i2c_scanner/src/main.c +++ b/samples/drivers/i2c_scanner/src/main.c @@ -38,7 +38,7 @@ void main(void) /* Send the address to read from */ msgs[0].buf = &dst; - msgs[0].len = 0; + msgs[0].len = 0U; msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP; if (i2c_transfer(i2c_dev, &msgs[0], 1, i) == 0) { diff --git a/samples/drivers/lcd_hd44780/src/main.c b/samples/drivers/lcd_hd44780/src/main.c index 98e955b2525..40f155990ec 100644 --- a/samples/drivers/lcd_hd44780/src/main.c +++ b/samples/drivers/lcd_hd44780/src/main.c @@ -461,7 +461,7 @@ void pi_lcd_init(struct device *gpio_dev, u8_t cols, u8_t rows, u8_t dotsize) _set_row_offsets(0x00, 0x40, 0x00 + cols, 0x40 + cols); /* For 1 line displays, a 10 pixel high font looks OK */ - if ((dotsize != LCD_5x8_DOTS) && (rows == 1)) { + if ((dotsize != LCD_5x8_DOTS) && (rows == 1U)) { lcd_data.disp_func |= LCD_5x10_DOTS; } @@ -563,7 +563,7 @@ void main(void) pi_lcd_set_cursor(gpio_dev, 19, 3); pi_lcd_left_to_right(gpio_dev); pi_lcd_string(gpio_dev, "********************"); - k_sleep(MSEC_PER_SEC * 3); + k_sleep(MSEC_PER_SEC * 3U); /* Clear display */ pi_lcd_clear(gpio_dev); @@ -579,7 +579,7 @@ void main(void) pi_lcd_string(gpio_dev, "My super RTOS"); pi_lcd_set_cursor(gpio_dev, 0, 3); pi_lcd_string(gpio_dev, "-------------------"); - k_sleep(MSEC_PER_SEC * 3); + k_sleep(MSEC_PER_SEC * 3U); /* Clear display */ pi_lcd_clear(gpio_dev); @@ -594,7 +594,7 @@ void main(void) pi_lcd_string(gpio_dev, "I am home!"); pi_lcd_set_cursor(gpio_dev, 0, 2); pi_lcd_string(gpio_dev, ""); - k_sleep(MSEC_PER_SEC * 3); + k_sleep(MSEC_PER_SEC * 3U); /* Clear display */ pi_lcd_clear(gpio_dev); diff --git a/samples/drivers/led_lp5562/src/main.c b/samples/drivers/led_lp5562/src/main.c index 168b7fe24fa..626a36d7239 100644 --- a/samples/drivers/led_lp5562/src/main.c +++ b/samples/drivers/led_lp5562/src/main.c @@ -53,7 +53,7 @@ static u8_t colors[COLORS_TO_SHOW][VALUES_PER_COLOR] = { */ static inline u8_t scale_color_to_percent(u8_t hex) { - return (hex * 100) / 0xFF; + return (hex * 100U) / 0xFF; } /* diff --git a/samples/drivers/rtc/src/main.c b/samples/drivers/rtc/src/main.c index 3545d3a750e..d8054840fff 100644 --- a/samples/drivers/rtc/src/main.c +++ b/samples/drivers/rtc/src/main.c @@ -28,8 +28,8 @@ void main(void) printk("Test RTC driver\n"); rtc_dev = device_get_binding(CONFIG_RTC_0_NAME); - config.init_val = 0; - config.alarm_enable = 1; + config.init_val = 0U; + config.alarm_enable = 1U; config.alarm_val = ALARM; config.cb_fn = test_rtc_interrupt_fn; diff --git a/samples/drivers/spi_fujitsu_fram/src/main.c b/samples/drivers/spi_fujitsu_fram/src/main.c index 374c1198308..676843e6c09 100644 --- a/samples/drivers/spi_fujitsu_fram/src/main.c +++ b/samples/drivers/spi_fujitsu_fram/src/main.c @@ -150,7 +150,7 @@ void main(void) } spi_cfg.operation = SPI_WORD_SET(8); - spi_cfg.frequency = 256000; + spi_cfg.frequency = 256000U; err = mb85rs64v_read_id(spi, &spi_cfg); diff --git a/samples/drivers/watchdog/src/main.c b/samples/drivers/watchdog/src/main.c index af88220563e..7beba515484 100644 --- a/samples/drivers/watchdog/src/main.c +++ b/samples/drivers/watchdog/src/main.c @@ -47,8 +47,8 @@ void main(void) wdt_config.flags = WDT_FLAG_RESET_SOC; /* Expire watchdog after 5000 milliseconds. */ - wdt_config.window.min = 0; - wdt_config.window.max = 5000; + wdt_config.window.min = 0U; + wdt_config.window.max = 5000U; /* Set up watchdog callback. Jump into it when watchdog expired. */ wdt_config.callback = wdt_callback; diff --git a/samples/gui/lvgl/src/main.c b/samples/gui/lvgl/src/main.c index 57fca8bf2d1..daa96bce738 100644 --- a/samples/gui/lvgl/src/main.c +++ b/samples/gui/lvgl/src/main.c @@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(app); void main(void) { - u32_t count = 0; + u32_t count = 0U; char count_str[11] = {0}; struct device *display_dev; lv_obj_t *hello_world_label; @@ -40,8 +40,8 @@ void main(void) display_blanking_off(display_dev); while (1) { - if ((count % 100) == 0) { - sprintf(count_str, "%d", count/100); + if ((count % 100) == 0U) { + sprintf(count_str, "%d", count/100U); lv_label_set_text(count_label, count_str); } lv_task_handler(); diff --git a/samples/net/google_iot_mqtt/src/protocol.c b/samples/net/google_iot_mqtt/src/protocol.c index 2a3a9c131ec..9e4a1a5436e 100644 --- a/samples/net/google_iot_mqtt/src/protocol.c +++ b/samples/net/google_iot_mqtt/src/protocol.c @@ -172,7 +172,7 @@ void mqtt_evt_handler(struct mqtt_client *const client, } /* increment message id for when we send next message */ - pub_data.message_id += 1; + pub_data.message_id += 1U; LOG_INF("PUBACK packet id: %u", evt->param.puback.message_id); break; @@ -350,8 +350,8 @@ void mqtt_startup(char *hostname, int port) subs_topic.topic.utf8 = subs_topic_str; subs_topic.topic.size = strlen(subs_topic_str); subs_list.list = &subs_topic; - subs_list.list_count = 1; - subs_list.message_id = 1; + subs_list.list_count = 1U; + subs_list.message_id = 1U; err = mqtt_subscribe(client, &subs_list); if (err) { @@ -364,9 +364,9 @@ void mqtt_startup(char *hostname, int port) pub_data.message.topic.topic.size = strlen(pub_topic); pub_data.message.topic.qos = MQTT_QOS_1_AT_LEAST_ONCE; pub_data.message.payload.data = (u8_t *)pub_msg; - pub_data.message_id = 1; - pub_data.dup_flag = 0; - pub_data.retain_flag = 1; + pub_data.message_id = 1U; + pub_data.dup_flag = 0U; + pub_data.retain_flag = 1U; mqtt_live(client); diff --git a/samples/net/mqtt_publisher/src/main.c b/samples/net/mqtt_publisher/src/main.c index 04ba5a280a3..84ce653ec8b 100644 --- a/samples/net/mqtt_publisher/src/main.c +++ b/samples/net/mqtt_publisher/src/main.c @@ -225,8 +225,8 @@ static int publish(struct mqtt_client *client, enum mqtt_qos qos) param.message.payload.len = strlen(param.message.payload.data); param.message_id = sys_rand32_get(); - param.dup_flag = 0; - param.retain_flag = 0; + param.dup_flag = 0U; + param.retain_flag = 0U; return mqtt_publish(client, ¶m); } diff --git a/samples/net/promiscuous_mode/src/main.c b/samples/net/promiscuous_mode/src/main.c index 02efce101b7..d775ebe3b26 100644 --- a/samples/net/promiscuous_mode/src/main.c +++ b/samples/net/promiscuous_mode/src/main.c @@ -59,7 +59,7 @@ static void print_info(struct net_pkt *pkt) { char src_addr_buf[NET_IPV6_ADDR_LEN], *src_addr; char dst_addr_buf[NET_IPV6_ADDR_LEN], *dst_addr; - u16_t dst_port = 0, src_port = 0; + u16_t dst_port = 0U, src_port = 0U; sa_family_t family = AF_UNSPEC; void *dst, *src; u8_t next_hdr; diff --git a/samples/net/sockets/can/src/main.c b/samples/net/sockets/can/src/main.c index 8d37b2c6e91..8ae5f3efb8c 100644 --- a/samples/net/sockets/can/src/main.c +++ b/samples/net/sockets/can/src/main.c @@ -27,7 +27,7 @@ static void tx(int *can_fd) struct can_frame frame = {0}; int ret, i; - msg.dlc = 8; + msg.dlc = 8U; msg.id_type = CAN_STANDARD_IDENTIFIER; msg.std_id = 0x1; msg.rtr = CAN_DATAFRAME; diff --git a/samples/net/sockets/coap_client/src/coap-client.c b/samples/net/sockets/coap_client/src/coap-client.c index 04dce342e63..e3f9876d304 100644 --- a/samples/net/sockets/coap_client/src/coap-client.c +++ b/samples/net/sockets/coap_client/src/coap-client.c @@ -61,7 +61,7 @@ static int start_coap_client(void) addr6.sin6_family = AF_INET6; addr6.sin6_port = htons(PEER_PORT); - addr6.sin6_scope_id = 0; + addr6.sin6_scope_id = 0U; inet_pton(AF_INET6, CONFIG_NET_CONFIG_PEER_IPV6_ADDR, &addr6.sin6_addr); @@ -585,7 +585,7 @@ static int register_observer(void) counter++; /* Unregister */ - if (counter == 5) { + if (counter == 5U) { /* TODO: Functionality can be verified byt waiting for * some time and make sure client shouldn't receive * any notifications. If client still receives diff --git a/samples/net/sockets/coap_server/src/coap-server.c b/samples/net/sockets/coap_server/src/coap-server.c index e9741ddee15..ebe19fee962 100644 --- a/samples/net/sockets/coap_server/src/coap-server.c +++ b/samples/net/sockets/coap_server/src/coap-server.c @@ -1060,7 +1060,7 @@ static int send_notification_packet(const struct sockaddr *addr, goto end; } - if (age >= 2) { + if (age >= 2U) { r = coap_append_option_int(&response, COAP_OPTION_OBSERVE, age); if (r < 0) { goto end; diff --git a/samples/net/sockets/echo_client/src/tcp.c b/samples/net/sockets/echo_client/src/tcp.c index 917af7d9e01..e3b4dca61e6 100644 --- a/samples/net/sockets/echo_client/src/tcp.c +++ b/samples/net/sockets/echo_client/src/tcp.c @@ -43,7 +43,7 @@ static int send_tcp_data(struct data *data) do { data->tcp.expecting = sys_rand32_get() % ipsum_len; - } while (data->tcp.expecting == 0); + } while (data->tcp.expecting == 0U); data->tcp.received = 0U; @@ -160,7 +160,7 @@ static int process_tcp_proto(struct data *data) data->proto, data->tcp.received); - if (++data->tcp.counter % 1000 == 0) { + if (++data->tcp.counter % 1000 == 0U) { LOG_INF("%s TCP: Exchanged %u packets", data->proto, data->tcp.counter); } diff --git a/samples/net/sockets/echo_client/src/udp.c b/samples/net/sockets/echo_client/src/udp.c index 5ee3ee48fb2..3cd30940072 100644 --- a/samples/net/sockets/echo_client/src/udp.c +++ b/samples/net/sockets/echo_client/src/udp.c @@ -32,7 +32,7 @@ static int send_udp_data(struct data *data) do { data->udp.expecting = sys_rand32_get() % ipsum_len; - } while (data->udp.expecting == 0); + } while (data->udp.expecting == 0U); ret = send(data->udp.sock, lorem_ipsum, data->udp.expecting, 0); @@ -158,7 +158,7 @@ static int process_udp_proto(struct data *data) LOG_DBG("%s UDP: Received and compared %d bytes, all ok", data->proto, received); - if (++data->udp.counter % 1000 == 0) { + if (++data->udp.counter % 1000 == 0U) { LOG_INF("%s UDP: Exchanged %u packets", data->proto, data->udp.counter); } diff --git a/samples/net/sockets/echo_server/src/tcp.c b/samples/net/sockets/echo_server/src/tcp.c index 8308932d7b5..8f274c2cf6f 100644 --- a/samples/net/sockets/echo_server/src/tcp.c +++ b/samples/net/sockets/echo_server/src/tcp.c @@ -158,7 +158,7 @@ static int process_tcp(struct data *data) LOG_DBG("TCP (%s): Received and replied with %d bytes", data->proto, offset); - if (++data->tcp.counter % 1000 == 0) { + if (++data->tcp.counter % 1000 == 0U) { LOG_INF("%s TCP: Sent %u packets", data->proto, data->tcp.counter); } diff --git a/samples/net/sockets/echo_server/src/udp.c b/samples/net/sockets/echo_server/src/udp.c index 25d93be91ac..1c447f677b4 100644 --- a/samples/net/sockets/echo_server/src/udp.c +++ b/samples/net/sockets/echo_server/src/udp.c @@ -115,7 +115,7 @@ static int process_udp(struct data *data) break; } - if (++data->udp.counter % 1000 == 0) { + if (++data->udp.counter % 1000 == 0U) { NET_INFO("%s UDP: Sent %u packets", data->proto, data->udp.counter); } diff --git a/samples/net/sockets/packet/src/packet.c b/samples/net/sockets/packet/src/packet.c index 1061930cf98..7fcd6b8876f 100644 --- a/samples/net/sockets/packet/src/packet.c +++ b/samples/net/sockets/packet/src/packet.c @@ -99,7 +99,7 @@ static void wait_send(struct k_work *work) static void send_packet(void) { struct sockaddr_ll dst; - u8_t send = 100; + u8_t send = 100U; int ret; dst.sll_ifindex = net_if_get_by_iface(net_if_get_default()); diff --git a/samples/net/wpan_serial/src/main.c b/samples/net/wpan_serial/src/main.c index 088d4cea02f..f31a1f558b0 100644 --- a/samples/net/wpan_serial/src/main.c +++ b/samples/net/wpan_serial/src/main.c @@ -436,7 +436,7 @@ static void tx_thread(void) hexdump("SLIP <", buf->data, buf->len); /* remove FCS 2 bytes */ - buf->len -= 2; + buf->len -= 2U; /* SLIP encode and send */ len = slip_buffer(slip_buf, buf); diff --git a/samples/net/zperf/src/shell_utils.c b/samples/net/zperf/src/shell_utils.c index 8f8ed86436e..7942b99b242 100644 --- a/samples/net/zperf/src/shell_utils.c +++ b/samples/net/zperf/src/shell_utils.c @@ -36,9 +36,9 @@ void print_number(const struct shell *shell, u32_t value, unit++; } - if (*div != 0) { + if (*div != 0U) { radix = value / *div; - dec = (value % *div) * 100 / *div; + dec = (value % *div) * 100U / *div; shell_fprintf(shell, SHELL_NORMAL, "%u.%s%u %s", radix, (dec < 10) ? "0" : "", dec, *unit); } else { @@ -61,7 +61,7 @@ long parse_number(const char *string, const u32_t *divisor, do { cmp = strncasecmp(suffix, *unit++, 1); - } while (cmp != 0 && *++div != 0); + } while (cmp != 0 && *++div != 0U); - return (*div == 0) ? dec : dec * *div; + return (*div == 0U) ? dec : dec * *div; } diff --git a/samples/net/zperf/src/zperf_shell.c b/samples/net/zperf/src/zperf_shell.c index cab5cbc05db..00290364bf6 100644 --- a/samples/net/zperf/src/zperf_shell.c +++ b/samples/net/zperf/src/zperf_shell.c @@ -362,21 +362,21 @@ static void shell_udp_upload_print_stats(const struct shell *shell, shell_fprintf(shell, SHELL_NORMAL, "-\nUpload completed!\n"); - if (results->time_in_us != 0) { + if (results->time_in_us != 0U) { rate_in_kbps = (u32_t) (((u64_t)results->nb_bytes_sent * (u64_t)8 * (u64_t)USEC_PER_SEC) / - ((u64_t)results->time_in_us * 1024)); + ((u64_t)results->time_in_us * 1024U)); } else { rate_in_kbps = 0U; } - if (results->client_time_in_us != 0) { + if (results->client_time_in_us != 0U) { client_rate_in_kbps = (u32_t) (((u64_t)results->nb_packets_sent * (u64_t)results->packet_size * (u64_t)8 * (u64_t)USEC_PER_SEC) / - ((u64_t)results->client_time_in_us * 1024)); + ((u64_t)results->client_time_in_us * 1024U)); } else { client_rate_in_kbps = 0U; } @@ -427,12 +427,12 @@ static void shell_tcp_upload_print_stats(const struct shell *shell, shell_fprintf(shell, SHELL_NORMAL, "-\nUpload completed!\n"); - if (results->client_time_in_us != 0) { + if (results->client_time_in_us != 0U) { client_rate_in_kbps = (u32_t) (((u64_t)results->nb_packets_sent * (u64_t)results->packet_size * (u64_t)8 * (u64_t)USEC_PER_SEC) / - ((u64_t)results->client_time_in_us * 1024)); + ((u64_t)results->client_time_in_us * 1024U)); } else { client_rate_in_kbps = 0U; } diff --git a/samples/net/zperf/src/zperf_tcp_receiver.c b/samples/net/zperf/src/zperf_tcp_receiver.c index 0e2c5150996..3ae5d92f271 100644 --- a/samples/net/zperf/src/zperf_tcp_receiver.c +++ b/samples/net/zperf/src/zperf_tcp_receiver.c @@ -81,12 +81,12 @@ static void tcp_received(struct net_context *context, session->state = STATE_COMPLETED; /* Compute baud rate */ - if (duration != 0) { + if (duration != 0U) { rate_in_kbps = (u32_t) (((u64_t)session->length * (u64_t)8 * (u64_t)USEC_PER_SEC) / - ((u64_t)duration * 1024)); + ((u64_t)duration * 1024U)); } else { rate_in_kbps = 0U; } diff --git a/samples/net/zperf/src/zperf_udp_receiver.c b/samples/net/zperf/src/zperf_udp_receiver.c index 75dc09ba10d..4f546bd3327 100644 --- a/samples/net/zperf/src/zperf_udp_receiver.c +++ b/samples/net/zperf/src/zperf_udp_receiver.c @@ -186,11 +186,11 @@ static void udp_received(struct net_context *context, session->state = STATE_COMPLETED; /* Compute baud rate */ - if (duration != 0) { + if (duration != 0U) { rate_in_kbps = (u32_t) (((u64_t)session->length * (u64_t)8 * (u64_t)USEC_PER_SEC) / - ((u64_t)duration * 1024)); + ((u64_t)duration * 1024U)); } else { rate_in_kbps = 0U; } diff --git a/samples/net/zperf/src/zperf_udp_uploader.c b/samples/net/zperf/src/zperf_udp_uploader.c index 4e1581c55ce..9d7c0337e85 100644 --- a/samples/net/zperf/src/zperf_udp_uploader.c +++ b/samples/net/zperf/src/zperf_udp_uploader.c @@ -164,8 +164,8 @@ void zperf_udp_upload(const struct shell *shell, struct zperf_results *results) { u32_t packet_duration = (u32_t)(((u64_t) packet_size * - SEC_TO_HW_CYCLES(1) * 8) / - (u64_t)(rate_in_kbps * 1024)); + SEC_TO_HW_CYCLES(1) * 8U) / + (u64_t)(rate_in_kbps * 1024U)); u32_t duration = MSEC_TO_HW_CYCLES(duration_in_ms); u32_t print_interval = SEC_TO_HW_CYCLES(1); u32_t delay = packet_duration; diff --git a/samples/portability/cmsis_rtos_v1/timer_synchronization/src/main.c b/samples/portability/cmsis_rtos_v1/timer_synchronization/src/main.c index 95ef5bbc24a..ae141bc2f7b 100644 --- a/samples/portability/cmsis_rtos_v1/timer_synchronization/src/main.c +++ b/samples/portability/cmsis_rtos_v1/timer_synchronization/src/main.c @@ -30,11 +30,11 @@ osMessageQId message_id; void read_msg_callback(void const *arg) { osEvent evt; - u32_t read_msg = 0; + u32_t read_msg = 0U; evt = osMessageGet(message_id, 0); read_msg = evt.value.v; - if (read_msg == 0) { + if (read_msg == 0U) { printk("\n**Error reading message from message queue**\n"); } else { printk("Read from message queue: %d\n\n", read_msg); @@ -57,7 +57,7 @@ int send_msg_thread(void) void main(void) { osTimerId timer_id; - u32_t counter = 10; + u32_t counter = 10U; data = INITIAL_DATA_VALUE; timer_id = osTimerCreate(osTimer(myTimer), osTimerPeriodic, NULL); @@ -85,7 +85,7 @@ void main(void) exit: osTimerDelete(timer_id); - if (counter == 0) { + if (counter == 0U) { printk("Sample execution successful\n"); } else { printk("Error in execution\n"); diff --git a/samples/portability/cmsis_rtos_v2/timer_synchronization/src/main.c b/samples/portability/cmsis_rtos_v2/timer_synchronization/src/main.c index 8bf23fc10f9..50c5e3672ef 100644 --- a/samples/portability/cmsis_rtos_v2/timer_synchronization/src/main.c +++ b/samples/portability/cmsis_rtos_v2/timer_synchronization/src/main.c @@ -67,7 +67,7 @@ void main(void) { osTimerId_t timer_id; osStatus_t status; - u32_t counter = 10; + u32_t counter = 10U; data = INITIAL_DATA_VALUE; @@ -100,7 +100,7 @@ void main(void) osTimerDelete(timer_id); exit: - if (counter == 0) { + if (counter == 0U) { printk("Sample execution successful\n"); } else { printk("Error in execution! \n"); diff --git a/samples/sensor/fxos8700-hid/src/main.c b/samples/sensor/fxos8700-hid/src/main.c index 926ed51ec4c..522af918e68 100644 --- a/samples/sensor/fxos8700-hid/src/main.c +++ b/samples/sensor/fxos8700-hid/src/main.c @@ -185,7 +185,7 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *tr) void main(void) { u8_t report[4] = { 0x00 }; - u8_t toggle = 0; + u8_t toggle = 0U; struct device *led_dev, *accel_dev, *hid_dev; led_dev = device_get_binding(LED_PORT); @@ -252,9 +252,9 @@ void main(void) report[MOUSE_BTN_REPORT_POS] = status[MOUSE_BTN_REPORT_POS]; report[MOUSE_X_REPORT_POS] = status[MOUSE_X_REPORT_POS]; - status[MOUSE_X_REPORT_POS] = 0; + status[MOUSE_X_REPORT_POS] = 0U; report[MOUSE_Y_REPORT_POS] = status[MOUSE_Y_REPORT_POS]; - status[MOUSE_Y_REPORT_POS] = 0; + status[MOUSE_Y_REPORT_POS] = 0U; hid_int_ep_write(hid_dev, report, sizeof(report), NULL); /* Toggle LED on sent report */ diff --git a/samples/subsys/ipc/openamp/remote/src/main.c b/samples/subsys/ipc/openamp/remote/src/main.c index 7d40ff2fb23..73ac52908cf 100644 --- a/samples/subsys/ipc/openamp/remote/src/main.c +++ b/samples/subsys/ipc/openamp/remote/src/main.c @@ -136,7 +136,7 @@ void app_task(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg2); ARG_UNUSED(arg3); int status = 0; - unsigned int message = 0; + unsigned int message = 0U; struct metal_device *device; struct rpmsg_device *rdev; struct metal_init_params metal_params = METAL_INIT_DEFAULTS; diff --git a/samples/subsys/ipc/openamp/src/main.c b/samples/subsys/ipc/openamp/src/main.c index b33613bb14c..d52b7ffe14c 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -161,7 +161,7 @@ void app_task(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg2); ARG_UNUSED(arg3); int status = 0; - unsigned int message = 0; + unsigned int message = 0U; struct metal_device *device; struct metal_init_params metal_params = METAL_INIT_DEFAULTS; diff --git a/samples/subsys/nvs/src/main.c b/samples/subsys/nvs/src/main.c index 2140c621e63..9b6c8fde79a 100644 --- a/samples/subsys/nvs/src/main.c +++ b/samples/subsys/nvs/src/main.c @@ -80,7 +80,7 @@ void main(void) printk("Unable to get page info"); } fs.sector_size = info.size; - fs.sector_count = 3; + fs.sector_count = 3U; rc = nvs_init(&fs, DT_FLASH_DEV_NAME); if (rc) { @@ -144,12 +144,12 @@ void main(void) printk("Id: %d, Data: %s\n", STRING_ID, buf); /* remove the item if reboot_counter = 10 */ - if (reboot_counter == 10) { + if (reboot_counter == 10U) { nvs_delete(&fs, STRING_ID); } } else { /* entry was not found, add it if reboot_counter = 0*/ - if (reboot_counter == 0) { + if (reboot_counter == 0U) { printk("Id: %d not found, adding it\n", STRING_ID); strcpy(buf, "DATA"); @@ -170,7 +170,7 @@ void main(void) printk("\n"); } else { /* entry was not found, add it if reboot_counter = 0*/ - if (reboot_counter == 0) { + if (reboot_counter == 0U) { printk("Longarray not found, adding it as id %d\n", LONG_ID); for (int n = 0; n < sizeof(longarray); n++) { @@ -226,7 +226,7 @@ void main(void) } else { printk("Reboot counter reached max value.\n"); printk("Reset to 0 and exit test.\n"); - reboot_counter = 0; + reboot_counter = 0U; nvs_write(&fs, RBT_CNT_ID, &reboot_counter, sizeof(reboot_counter)); break; diff --git a/samples/subsys/shell/shell_module/src/dynamic_cmd.c b/samples/subsys/shell/shell_module/src/dynamic_cmd.c index f9ac0097edc..8f00befe7ac 100644 --- a/samples/subsys/shell/shell_module/src/dynamic_cmd.c +++ b/samples/subsys/shell/shell_module/src/dynamic_cmd.c @@ -122,7 +122,7 @@ static int cmd_dynamic_show(const struct shell *shell, ARG_UNUSED(argc); ARG_UNUSED(argv); - if (dynamic_cmd_cnt == 0) { + if (dynamic_cmd_cnt == 0U) { shell_warn(shell, "Please add some commands first."); return -ENOEXEC; } diff --git a/samples/subsys/usb/hid-cdc/src/main.c b/samples/subsys/usb/hid-cdc/src/main.c index 7436bda2006..fa7f05d1939 100644 --- a/samples/subsys/usb/hid-cdc/src/main.c +++ b/samples/subsys/usb/hid-cdc/src/main.c @@ -281,7 +281,7 @@ static int ascii_to_hid(u8_t ascii) } } else if (ascii < 58) { /* Numbers */ - if (ascii == 48) { + if (ascii == 48U) { return HID_KEY_0; } else { return ascii - 19; @@ -308,7 +308,7 @@ static int ascii_to_hid(u8_t ascii) } } else if (ascii < 91) { /* Uppercase characters */ - return ascii - 61; + return ascii - 61U; } else if (ascii < 97) { /* Special characters #3 */ switch (ascii) { @@ -353,19 +353,19 @@ static int ascii_to_hid(u8_t ascii) static bool needs_shift(u8_t ascii) { - if ((ascii < 33) || (ascii == 39)) { + if ((ascii < 33) || (ascii == 39U)) { return false; - } else if ((ascii >= 33) && (ascii < 44)) { + } else if ((ascii >= 33U) && (ascii < 44)) { return true; - } else if ((ascii >= 44) && (ascii < 58)) { + } else if ((ascii >= 44U) && (ascii < 58)) { return false; - } else if ((ascii == 59) || (ascii == 61)) { + } else if ((ascii == 59U) || (ascii == 61U)) { return false; - } else if ((ascii >= 58) && (ascii < 91)) { + } else if ((ascii >= 58U) && (ascii < 91)) { return true; - } else if ((ascii >= 91) && (ascii < 94)) { + } else if ((ascii >= 91U) && (ascii < 94)) { return false; - } else if ((ascii == 94) || (ascii == 95)) { + } else if ((ascii == 94U) || (ascii == 95U)) { return true; } else if ((ascii > 95) && (ascii < 123)) { return false; @@ -383,13 +383,13 @@ static volatile bool data_arrived; static void flush_buffer_mouse(void) { - chr_ptr_mouse = 0; + chr_ptr_mouse = 0U; memset(data_buf_mouse, 0, sizeof(data_buf_mouse)); } static void flush_buffer_kbd(void) { - chr_ptr_kbd = 0; + chr_ptr_kbd = 0U; memset(data_buf_kbd, 0, sizeof(data_buf_kbd)); } @@ -695,7 +695,7 @@ void main(void) ev->event_type = HID_KBD_STRING, app_evt_put(ev); - str_pointer = 0; + str_pointer = 0U; k_sem_give(&evt_sem); } break; diff --git a/samples/subsys/usb/hid-mouse/src/main.c b/samples/subsys/usb/hid-mouse/src/main.c index af33b18cc69..67414abe737 100644 --- a/samples/subsys/usb/hid-mouse/src/main.c +++ b/samples/subsys/usb/hid-mouse/src/main.c @@ -163,7 +163,7 @@ static void x_move(struct device *gpio, struct gpio_callback *cb, u32_t pins) gpio_pin_read(gpio, PIN2, &cur_val); if (def_val[2] != cur_val) { - state += 10; + state += 10U; } if (status[MOUSE_X_REPORT_POS] != state) { @@ -182,7 +182,7 @@ static void y_move(struct device *gpio, struct gpio_callback *cb, u32_t pins) gpio_pin_read(gpio, PIN3, &cur_val); if (def_val[3] != cur_val) { - state += 10; + state += 10U; } if (status[MOUSE_Y_REPORT_POS] != state) { @@ -214,7 +214,7 @@ int callbacks_configure(struct device *gpio, u32_t pin, int flags, void main(void) { u8_t report[4] = { 0x00 }; - u8_t toggle = 0; + u8_t toggle = 0U; struct device *led_dev, *hid_dev; led_dev = device_get_binding(LED_PORT); @@ -274,9 +274,9 @@ void main(void) report[MOUSE_BTN_REPORT_POS] = status[MOUSE_BTN_REPORT_POS]; report[MOUSE_X_REPORT_POS] = status[MOUSE_X_REPORT_POS]; - status[MOUSE_X_REPORT_POS] = 0; + status[MOUSE_X_REPORT_POS] = 0U; report[MOUSE_Y_REPORT_POS] = status[MOUSE_Y_REPORT_POS]; - status[MOUSE_Y_REPORT_POS] = 0; + status[MOUSE_Y_REPORT_POS] = 0U; hid_int_ep_write(hid_dev, report, sizeof(report), NULL); /* Toggle LED on sent report */ diff --git a/samples/subsys/usb/webusb/src/main.c b/samples/subsys/usb/webusb/src/main.c index 08744dc0728..449e15f0a8b 100644 --- a/samples/subsys/usb/webusb/src/main.c +++ b/samples/subsys/usb/webusb/src/main.c @@ -241,7 +241,7 @@ int vendor_handle_req(struct usb_setup_packet *pSetup, /* Get URL request */ u8_t index = GET_DESC_INDEX(pSetup->wValue); - if (index == 0 || index > NUMBER_OF_ALLOWED_ORIGINS) + if (index == 0U || index > NUMBER_OF_ALLOWED_ORIGINS) return -ENOTSUP; *data = (u8_t *)(&webusb_origin_url); diff --git a/soc/arc/snps_arc_iot/sysconf.c b/soc/arc/snps_arc_iot/sysconf.c index eab050b8cca..11a34e93427 100644 --- a/soc/arc/snps_arc_iot/sysconf.c +++ b/soc/arc/snps_arc_iot/sysconf.c @@ -78,7 +78,7 @@ int32_t arc_iot_pll_fout_config(uint32_t freq) sysconf_reg_ptr->CLKSEL = CLKSEL_EXT_16M; } - for (i = 0; i < ARRAY_SIZE(pll_configuration); i++) { + for (i = 0U; i < ARRAY_SIZE(pll_configuration); i++) { if (pll_configuration[i].fout == freq) { break; } diff --git a/soc/arm/atmel_sam/common/soc_gpio.c b/soc/arm/atmel_sam/common/soc_gpio.c index 950c99c68d9..23911479b39 100644 --- a/soc/arm/atmel_sam/common/soc_gpio.c +++ b/soc/arm/atmel_sam/common/soc_gpio.c @@ -54,7 +54,7 @@ static void configure_common_attr(Pio *pio, u32_t mask, u32_t flags) static void configure_input_attr(Pio *pio, u32_t mask, u32_t flags) { /* Configure input filter */ - if ((flags & SOC_GPIO_IN_FILTER_MASK) != 0) { + if ((flags & SOC_GPIO_IN_FILTER_MASK) != 0U) { if ((flags & SOC_GPIO_IN_FILTER_MASK) == SOC_GPIO_IN_FILTER_DEBOUNCE) { /* Enable de-bounce, disable de-glitch */ #if defined PIO_IFSCER_P0 diff --git a/soc/riscv32/openisa_rv32m1/soc.c b/soc/riscv32/openisa_rv32m1/soc.c index 20248339da4..c3f09b568ec 100644 --- a/soc/riscv32/openisa_rv32m1/soc.c +++ b/soc/riscv32/openisa_rv32m1/soc.c @@ -71,7 +71,7 @@ void z_arch_irq_enable(unsigned int irq) if (IS_ENABLED(CONFIG_MULTI_LEVEL_INTERRUPTS)) { unsigned int level = rv32m1_irq_level(irq); - if (level == 1) { + if (level == 1U) { EVENT_UNIT->INTPTEN |= BIT(rv32m1_level1_irq(irq)); /* Ensures write has finished: */ (void)(EVENT_UNIT->INTPTEN); @@ -89,7 +89,7 @@ void z_arch_irq_disable(unsigned int irq) if (IS_ENABLED(CONFIG_MULTI_LEVEL_INTERRUPTS)) { unsigned int level = rv32m1_irq_level(irq); - if (level == 1) { + if (level == 1U) { EVENT_UNIT->INTPTEN &= ~BIT(rv32m1_level1_irq(irq)); /* Ensures write has finished: */ (void)(EVENT_UNIT->INTPTEN); @@ -107,7 +107,7 @@ int z_arch_irq_is_enabled(unsigned int irq) if (IS_ENABLED(CONFIG_MULTI_LEVEL_INTERRUPTS)) { unsigned int level = rv32m1_irq_level(irq); - if (level == 1) { + if (level == 1U) { return (EVENT_UNIT->INTPTEN & BIT(rv32m1_level1_irq(irq))) != 0; } else { @@ -124,7 +124,7 @@ int z_arch_irq_is_enabled(unsigned int irq) line = rv32m1_intmux_line(irq); ier = INTMUX->CHANNEL[channel].CHn_IER_31_0 & BIT(line); - return ier != 0; + return ier != 0U; } } else { return (EVENT_UNIT->INTPTEN & BIT(rv32m1_level1_irq(irq))) != 0; diff --git a/soc/riscv32/openisa_rv32m1/soc.h b/soc/riscv32/openisa_rv32m1/soc.h index 2604fd0f763..bb9f803e47d 100644 --- a/soc/riscv32/openisa_rv32m1/soc.h +++ b/soc/riscv32/openisa_rv32m1/soc.h @@ -34,7 +34,7 @@ */ static inline unsigned int rv32m1_irq_level(unsigned int irq) { - return ((irq >> 8) & 0xff) == 0 ? 1 : 2; + return ((irq >> 8) & 0xff) == 0U ? 1 : 2; } /** diff --git a/soc/x86/intel_quark/include/pinmux_quark_mcu.h b/soc/x86/intel_quark/include/pinmux_quark_mcu.h index 67df4d5a300..c8b1bca3efc 100644 --- a/soc/x86/intel_quark/include/pinmux_quark_mcu.h +++ b/soc/x86/intel_quark/include/pinmux_quark_mcu.h @@ -40,7 +40,7 @@ static inline int _quark_mcu_set_mux(u32_t base, u32_t pin, u8_t func) * the registers are 32-bit wide, but each pin requires 1 bit * to set the input enable bit. */ - u32_t register_offset = (pin / 32) * 4; + u32_t register_offset = (pin / 32) * 4U; /* * Now figure out what is the full address for the register * we are looking for. Add the base register to the register_mask diff --git a/soc/x86/intel_quark/quark_se/soc.c b/soc/x86/intel_quark/quark_se/soc.c index 6b70410f663..334b339d477 100644 --- a/soc/x86/intel_quark/quark_se/soc.c +++ b/soc/x86/intel_quark/quark_se/soc.c @@ -68,7 +68,7 @@ int _arc_init(struct device *arg) ARG_UNUSED(arg); - if (SCSS_REG_VAL(SCSS_SS_STS) == 0) { + if (SCSS_REG_VAL(SCSS_SS_STS) == 0U) { /* ARC shouldn't already be running! */ printk("ARC core already running!"); return -EIO; @@ -81,7 +81,7 @@ int _arc_init(struct device *arg) LOG_DBG("Reset vector address: %x", *reset_vector); shared_data->arc_start = *reset_vector; shared_data->flags = 0U; - if (shared_data->arc_start == 0) { + if (shared_data->arc_start == 0U) { /* Reset vector points to NULL => skip ARC init. */ LOG_DBG("Reset vector is NULL, skipping ARC init."); goto skip_arc_init; @@ -94,13 +94,13 @@ int _arc_init(struct device *arg) LOG_DBG("Waiting for arc to start..."); /* Block until the ARC core actually starts up */ - while ((SCSS_REG_VAL(SCSS_SS_STS) & 0x4000) != 0) { + while ((SCSS_REG_VAL(SCSS_SS_STS) & 0x4000) != 0U) { } /* Block until ARC's quark_se_init() sets a flag indicating it is ready, * if we get stuck here ARC has run but has exploded very early */ LOG_DBG("Waiting for arc to init..."); - while ((shared_data->flags & ARC_READY) == 0) { + while ((shared_data->flags & ARC_READY) == 0U) { } skip_arc_init: diff --git a/soc/xtensa/intel_s1000/soc.c b/soc/xtensa/intel_s1000/soc.c index b5e9a863afe..7842fc26415 100644 --- a/soc/xtensa/intel_s1000/soc.c +++ b/soc/xtensa/intel_s1000/soc.c @@ -201,7 +201,7 @@ static inline void soc_set_dmic_power(void) /* enable power */ dmic_shim_regs->dmiclctl |= SOC_DMIC_SHIM_DMICLCTL_SPA; - while ((dmic_shim_regs->dmiclctl & SOC_DMIC_SHIM_DMICLCTL_CPA) == 0) { + while ((dmic_shim_regs->dmiclctl & SOC_DMIC_SHIM_DMICLCTL_CPA) == 0U) { /* wait for power status */ } #endif @@ -215,7 +215,7 @@ static inline void soc_set_gna_power(void) /* power on GNA block */ regs->gna_power_control |= SOC_GNA_POWER_CONTROL_SPA; - while ((regs->gna_power_control & SOC_GNA_POWER_CONTROL_CPA) == 0) { + while ((regs->gna_power_control & SOC_GNA_POWER_CONTROL_CPA) == 0U) { /* wait for power status */ } diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index 616d8a58c3b..5acf21032f9 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -120,7 +120,7 @@ static void *cmd_complete(struct net_buf **buf, u8_t plen) evt_create(*buf, BT_HCI_EVT_CMD_COMPLETE, sizeof(*cc) + plen); cc = net_buf_add(*buf, sizeof(*cc)); - cc->ncmd = 1; + cc->ncmd = 1U; cc->opcode = sys_cpu_to_le16(_opcode); return net_buf_add(*buf, plen); @@ -137,7 +137,7 @@ static struct net_buf *cmd_status(u8_t status) cs = net_buf_add(buf, sizeof(*cs)); cs->status = status; - cs->ncmd = 1; + cs->ncmd = 1U; cs->opcode = sys_cpu_to_le16(_opcode); return buf; @@ -244,7 +244,7 @@ static void reset(struct net_buf *buf, struct net_buf **evt) int i; for (i = 0; i < ARRAY_SIZE(scan_filters); i++) { - scan_filters[i].count = 0; + scan_filters[i].count = 0U; } sf_curr = 0xFF; #endif @@ -1384,7 +1384,7 @@ static void le_set_phy(struct net_buf *buf, struct net_buf **evt) } if (phy_opts & 0x03) { - phy_opts -= 1; + phy_opts -= 1U; phy_opts &= 1; } else { phy_opts = 0U; @@ -1813,7 +1813,7 @@ static void vs_read_version_info(struct net_buf *buf, struct net_buf **evt) rp->hw_platform = sys_cpu_to_le16(BT_HCI_VS_HW_PLAT); rp->hw_variant = sys_cpu_to_le16(BT_HCI_VS_HW_VAR); - rp->fw_variant = 0; + rp->fw_variant = 0U; rp->fw_version = (KERNEL_VERSION_MAJOR & 0xff); rp->fw_revision = sys_cpu_to_le16(KERNEL_VERSION_MINOR); rp->fw_build = sys_cpu_to_le32(KERNEL_PATCHLEVEL & 0xffff); @@ -1900,7 +1900,7 @@ static void vs_read_static_addrs(struct net_buf *buf, struct net_buf **evt) rp = cmd_complete(evt, sizeof(*rp) + sizeof(*addr)); rp->status = 0x00; - rp->num_addrs = 1; + rp->num_addrs = 1U; addr = &rp->a[0]; sys_put_le32(NRF_FICR->DEVICEADDR[0], &addr->bdaddr.val[0]); @@ -1920,7 +1920,7 @@ static void vs_read_static_addrs(struct net_buf *buf, struct net_buf **evt) rp = cmd_complete(evt, sizeof(*rp)); rp->status = 0x00; - rp->num_addrs = 0; + rp->num_addrs = 0U; } static void vs_read_key_hierarchy_roots(struct net_buf *buf, @@ -1988,7 +1988,7 @@ static void mesh_get_opts(struct net_buf *buf, struct net_buf **evt) rp->max_tx_power = 4; rp->max_scan_filter = CONFIG_BT_CTLR_MESH_SCAN_FILTERS; rp->max_filter_pattern = CONFIG_BT_CTLR_MESH_SF_PATTERNS; - rp->max_adv_slot = 1; + rp->max_adv_slot = 1U; rp->evt_prefix_len = 0x01; rp->evt_prefix = BT_HCI_MESH_EVT_PREFIX; } @@ -2020,7 +2020,7 @@ static void mesh_set_scan_filter(struct net_buf *buf, struct net_buf **evt) } f = &scan_filters[filter]; - for (i = 0; i < cmd->num_patterns; i++) { + for (i = 0U; i < cmd->num_patterns; i++) { if (!cmd->patterns[i].pattern_len || cmd->patterns[i].pattern_len > BT_HCI_MESH_PATTERN_LEN_MAX) { @@ -2391,7 +2391,7 @@ static inline void le_dir_adv_report(struct pdu_adv *adv, struct net_buf *buf, drp = meta_evt(buf, BT_HCI_EVT_LE_DIRECT_ADV_REPORT, sizeof(*drp) + sizeof(*dir_info)); - drp->num_reports = 1; + drp->num_reports = 1U; dir_info = (void *)(((u8_t *)drp) + sizeof(*drp)); /* Directed Advertising */ @@ -2403,7 +2403,7 @@ static inline void le_dir_adv_report(struct pdu_adv *adv, struct net_buf *buf, ll_rl_id_addr_get(rl_idx, &dir_info->addr.type, &dir_info->addr.a.val[0]); /* Mark it as identity address from RPA (0x02, 0x03) */ - dir_info->addr.type += 2; + dir_info->addr.type += 2U; } else { #else if (1) { @@ -2465,7 +2465,7 @@ static inline void le_mesh_scan_report(struct pdu_adv *adv, struct net_buf *buf, mep = mesh_evt(buf, BT_HCI_EVT_MESH_SCANNING_REPORT, sizeof(*mep) + sizeof(*sr)); - mep->num_reports = 1; + mep->num_reports = 1U; sr = (void *)(((u8_t *)mep) + sizeof(*mep)); sr->addr.type = adv->tx_addr; memcpy(&sr->addr.a.val[0], &adv->adv_ind.addr[0], sizeof(bt_addr_t)); @@ -2549,14 +2549,14 @@ static void le_advertising_report(struct pdu_data *pdu_data, u8_t *b, if (adv->type != PDU_ADV_TYPE_DIRECT_IND) { data_len = (adv->len - BDADDR_SIZE); } else { - data_len = 0; + data_len = 0U; } info_len = sizeof(struct bt_hci_evt_le_advertising_info) + data_len + sizeof(*prssi); sep = meta_evt(buf, BT_HCI_EVT_LE_ADVERTISING_REPORT, sizeof(*sep) + info_len); - sep->num_reports = 1; + sep->num_reports = 1U; adv_info = (void *)(((u8_t *)sep) + sizeof(*sep)); adv_info->evt_type = c_adv_type[adv->type]; @@ -2567,7 +2567,7 @@ static void le_advertising_report(struct pdu_data *pdu_data, u8_t *b, ll_rl_id_addr_get(rl_idx, &adv_info->addr.type, &adv_info->addr.a.val[0]); /* Mark it as identity address from RPA (0x02, 0x03) */ - adv_info->addr.type += 2; + adv_info->addr.type += 2U; } else { #else if (1) { @@ -2675,7 +2675,7 @@ static void le_scan_req_received(struct pdu_data *pdu_data, u8_t *b, u8_t handle; s8_t rssi; - handle = 0; + handle = 0U; addr.type = adv->tx_addr; memcpy(&addr.a.val[0], &adv->scan_req.scan_addr[0], sizeof(bt_addr_t)); @@ -2692,7 +2692,7 @@ static void le_scan_req_received(struct pdu_data *pdu_data, u8_t *b, } sep = meta_evt(buf, BT_HCI_EVT_LE_SCAN_REQ_RECEIVED, sizeof(*sep)); - sep->handle = 0; + sep->handle = 0U; sep->addr.type = adv->tx_addr; memcpy(&sep->addr.a.val[0], &adv->scan_req.scan_addr[0], sizeof(bt_addr_t)); diff --git a/subsys/bluetooth/controller/hci/hci_driver.c b/subsys/bluetooth/controller/hci/hci_driver.c index 0318c658378..41f3228910a 100644 --- a/subsys/bluetooth/controller/hci/hci_driver.c +++ b/subsys/bluetooth/controller/hci/hci_driver.c @@ -330,7 +330,7 @@ static void recv_thread(void *p1, void *p2, void *p3) err = k_poll(events, 2, K_FOREVER); LL_ASSERT(err == 0); if (events[0].state == K_POLL_STATE_SIGNALED) { - events[0].signal->signaled = 0; + events[0].signal->signaled = 0U; } else if (events[1].state == K_POLL_STATE_FIFO_DATA_AVAILABLE) { node_rx = k_fifo_get(events[1].fifo, 0); diff --git a/subsys/bluetooth/controller/ll_sw/ll_filter.c b/subsys/bluetooth/controller/ll_sw/ll_filter.c index 2d399efb762..8ac4f8231c4 100644 --- a/subsys/bluetooth/controller/ll_sw/ll_filter.c +++ b/subsys/bluetooth/controller/ll_sw/ll_filter.c @@ -504,7 +504,7 @@ bool ctrl_rl_addr_resolve(u8_t id_addr_type, u8_t *id_addr, u8_t rl_idx) return false; } - if ((id_addr_type != 0) && ((id_addr[5] & 0xc0) == 0x40)) { + if ((id_addr_type != 0U) && ((id_addr[5] & 0xc0) == 0x40)) { return bt_rpa_irk_matches(rl[rl_idx].local_irk, (bt_addr_t *)id_addr); } @@ -892,7 +892,7 @@ u8_t ll_rl_enable(u8_t enable) void ll_rl_timeout_set(u16_t timeout) { - rpa_timeout_ms = timeout * 1000; + rpa_timeout_ms = timeout * 1000U; } u8_t ll_priv_mode_set(bt_addr_le_t *id_addr, u8_t mode) diff --git a/subsys/bluetooth/controller/ll_sw/ll_mesh.c b/subsys/bluetooth/controller/ll_sw/ll_mesh.c index fc6caa79511..c903726dfa8 100644 --- a/subsys/bluetooth/controller/ll_sw/ll_mesh.c +++ b/subsys/bluetooth/controller/ll_sw/ll_mesh.c @@ -27,7 +27,7 @@ u8_t ll_mesh_advertise(u8_t handle, u8_t own_addr_type, u8_t err; /* convert to 625 us units for internal use */ - interval = ((u32_t)interval + 1) * 10000 / 625; + interval = ((u32_t)interval + 1) * 10000U / 625; #if defined(CONFIG_BT_CTLR_ADV_EXT) /* Non-conn Non-Scan advertising */ @@ -58,7 +58,7 @@ u8_t ll_mesh_advertise(u8_t handle, u8_t own_addr_type, /* TODO: calculate random tx delay */ ticks_anchor = ticker_ticks_now_get(); - ticks_anchor += HAL_TICKER_US_TO_TICKS(min_tx_delay * 10000); + ticks_anchor += HAL_TICKER_US_TO_TICKS(min_tx_delay * 10000U); /* Enable advertising instance */ err = ll_adv_enable(handle, 1, diff --git a/subsys/bluetooth/controller/ll_sw/ll_test.c b/subsys/bluetooth/controller/ll_sw/ll_test.c index 8656cbea4a4..15cbe61ccab 100644 --- a/subsys/bluetooth/controller/ll_sw/ll_test.c +++ b/subsys/bluetooth/controller/ll_sw/ll_test.c @@ -94,7 +94,7 @@ static void isr_tx(void *param) #endif /* CONFIG_BT_CTLR_GPIO_PA_PIN */ /* Exit if radio disabled */ - if (((tx_req - tx_ack) & 0x01) == 0) { + if (((tx_req - tx_ack) & 0x01) == 0U) { tx_ack = tx_req; return; @@ -102,7 +102,7 @@ static void isr_tx(void *param) /* LE Test Packet Interval */ l = radio_tmr_end_get() - radio_tmr_ready_get(); - i = ((l + 249 + 624) / 625) * 625; + i = ((l + 249 + 624) / 625) * 625U; t = radio_tmr_end_get() - l + i; t -= radio_tx_ready_delay_get(test_phy, test_phy_flags); @@ -110,7 +110,7 @@ static void isr_tx(void *param) radio_tmr_sample(); s = radio_tmr_sample_get(); while (t < s) { - t += 625; + t += 625U; } /* Setup next Tx */ diff --git a/subsys/bluetooth/controller/ll_sw/lll.h b/subsys/bluetooth/controller/ll_sw/lll.h index 31ab6d549dc..836369fe981 100644 --- a/subsys/bluetooth/controller/ll_sw/lll.h +++ b/subsys/bluetooth/controller/ll_sw/lll.h @@ -245,7 +245,7 @@ static inline void lll_hdr_init(void *lll, void *parent) struct lll_hdr *hdr = lll; hdr->parent = parent; - hdr->is_stop = 0; + hdr->is_stop = 0U; } static inline int lll_stop(void *lll) @@ -253,7 +253,7 @@ static inline int lll_stop(void *lll) struct lll_hdr *hdr = lll; int ret = !!hdr->is_stop; - hdr->is_stop = 1; + hdr->is_stop = 1U; return ret; } diff --git a/subsys/bluetooth/controller/ll_sw/lll_chan.c b/subsys/bluetooth/controller/ll_sw/lll_chan.c index fcb9617c74c..4d585527faa 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_chan.c +++ b/subsys/bluetooth/controller/ll_sw/lll_chan.c @@ -59,7 +59,7 @@ u8_t lll_chan_sel_1(u8_t *chan_use, u8_t hop, u16_t latency, u8_t *chan_map, chan_next = ((*chan_use) + (hop * (1 + latency))) % 37; *chan_use = chan_next; - if ((chan_map[chan_next >> 3] & (1 << (chan_next % 8))) == 0) { + if ((chan_map[chan_next >> 3] & (1 << (chan_next % 8))) == 0U) { u8_t chan_index; chan_index = chan_next % chan_count; @@ -82,7 +82,7 @@ u8_t lll_chan_sel_2(u16_t counter, u16_t chan_id, u8_t *chan_map, prn_e = chan_prn(counter, chan_id); chan_next = prn_e % 37; - if ((chan_map[chan_next >> 3] & (1 << (chan_next % 8))) == 0) { + if ((chan_map[chan_next >> 3] & (1 << (chan_next % 8))) == 0U) { u8_t chan_index; chan_index = ((u32_t)chan_count * prn_e) >> 16; @@ -101,17 +101,17 @@ static u8_t chan_sel_remap(u8_t *chan_map, u8_t chan_index) u8_t chan_next; u8_t byte_count; - chan_next = 0; - byte_count = 5; + chan_next = 0U; + byte_count = 5U; while (byte_count--) { u8_t bite; u8_t bit_count; bite = *chan_map; - bit_count = 8; + bit_count = 8U; while (bit_count--) { if (bite & 0x01) { - if (chan_index == 0) { + if (chan_index == 0U) { break; } chan_index--; @@ -139,22 +139,22 @@ void lll_chan_sel_2_ut(void) u8_t m; m = chan_sel_2(1, 0x305F, chan_map_1, 37); - LL_ASSERT(m == 20); + LL_ASSERT(m == 20U); m = chan_sel_2(2, 0x305F, chan_map_1, 37); - LL_ASSERT(m == 6); + LL_ASSERT(m == 6U); m = chan_sel_2(3, 0x305F, chan_map_1, 37); - LL_ASSERT(m == 21); + LL_ASSERT(m == 21U); m = chan_sel_2(6, 0x305F, chan_map_2, 9); - LL_ASSERT(m == 23); + LL_ASSERT(m == 23U); m = chan_sel_2(7, 0x305F, chan_map_2, 9); - LL_ASSERT(m == 9); + LL_ASSERT(m == 9U); m = chan_sel_2(8, 0x305F, chan_map_2, 9); - LL_ASSERT(m == 34); + LL_ASSERT(m == 34U); } #endif /* RADIO_UNIT_TEST */ @@ -176,7 +176,7 @@ static u16_t chan_perm(u16_t i) static u16_t chan_mam(u16_t a, u16_t b) { - return ((u32_t)a * 17 + b) & 0xFFFF; + return ((u32_t)a * 17U + b) & 0xFFFF; } static u16_t chan_prn(u16_t counter, u16_t chan_id) @@ -186,7 +186,7 @@ static u16_t chan_prn(u16_t counter, u16_t chan_id) prn_e = counter ^ chan_id; - for (iterate = 0; iterate < 3; iterate++) { + for (iterate = 0U; iterate < 3; iterate++) { prn_e = chan_perm(prn_e); prn_e = chan_mam(prn_e, chan_id); } diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c index e3923f688ea..8868eda7f2c 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c @@ -193,7 +193,7 @@ u32_t ecb_ut(void) __WFE(); } while (!context.done); - if (context.status != 0) { + if (context.status != 0U) { return context.status; } diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c index 7aca89c1f42..cb83bd35f95 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c @@ -519,7 +519,7 @@ static void sw_switch(u8_t dir, u8_t phy_curr, u8_t flags_curr, u8_t phy_next, radio_tmr_end_capture(); #endif /* CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - sw_tifs_toggle += 1; + sw_tifs_toggle += 1U; sw_tifs_toggle &= 1; } #endif /* CONFIG_BT_CTLR_TIFS_HW */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c index 8918d49b556..d7066b56b9a 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c @@ -408,7 +408,7 @@ static void isr_rx(void *param) irkmatch_id = radio_ar_match_get(); rssi_ready = radio_rssi_is_ready(); } else { - crc_ok = devmatch_ok = irkmatch_ok = rssi_ready = 0; + crc_ok = devmatch_ok = irkmatch_ok = rssi_ready = 0U; devmatch_id = irkmatch_id = 0xFF; } @@ -570,7 +570,7 @@ static void chan_prepare(struct lll_adv *lll) struct pdu_adv *pdu; struct pdu_adv *scan_pdu; u8_t chan; - u8_t upd = 0; + u8_t upd = 0U; pdu = lll_adv_data_latest_get(lll, &upd); scan_pdu = lll_adv_scan_rsp_latest_get(lll, &upd); @@ -745,7 +745,7 @@ static inline bool isr_rx_sr_check(struct lll_adv *lll, struct pdu_adv *adv, (devmatch_ok || ctrl_irk_whitelisted(*rl_idx)))) && isr_rx_sr_adva_check(adv, sr); #else - return (((lll->filter_policy & 0x01) == 0) || devmatch_ok) && + return (((lll->filter_policy & 0x01) == 0U) || devmatch_ok) && isr_rx_sr_adva_check(adv, sr); #endif /* CONFIG_BT_CTLR_PRIVACY */ } diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h index 500a2980b32..70bb4e9abeb 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h @@ -51,7 +51,7 @@ static inline struct pdu_adv *lll_adv_pdu_alloc(struct lll_adv_pdu *pdu, if (pdu->first == pdu->last) { last = pdu->last + 1; if (last == DOUBLE_BUFFER_SIZE) { - last = 0; + last = 0U; } } else { last = pdu->last; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_internal.h b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_internal.h index 386797e215f..197fae8479f 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_internal.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_internal.h @@ -11,12 +11,12 @@ static inline struct pdu_adv *lll_adv_pdu_latest_get(struct lll_adv_pdu *pdu, first = pdu->first; if (first != pdu->last) { - first += 1; + first += 1U; if (first == DOUBLE_BUFFER_SIZE) { - first = 0; + first = 0U; } pdu->first = first; - *is_modified = 1; + *is_modified = 1U; } return (void *)pdu->pdu[first]; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c index 1ca5a4cec46..4e4efd3985b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c @@ -24,7 +24,7 @@ void lll_clock_wait(void) if (!is_k32src_stable) { struct device *clk_k32; - is_k32src_stable = 1; + is_k32src_stable = 1U; clk_k32 = device_get_binding(DRV_NAME); LL_ASSERT(clk_k32); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c index 62b2afa8b55..8ec0118f4fc 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c @@ -96,9 +96,9 @@ u32_t lll_conn_ppm_get(u8_t sca) void lll_conn_prepare_reset(void) { - trx_cnt = 0; - crc_expire = 0; - crc_valid = 0; + trx_cnt = 0U; + crc_expire = 0U; + crc_valid = 0U; #if defined(CONFIG_BT_CTLR_LE_ENC) mic_state = LLL_CONN_MIC_NONE; @@ -143,9 +143,9 @@ void lll_conn_isr_rx(void *param) struct pdu_data *pdu_data_tx; struct node_rx_pdu *node_rx; u8_t is_empty_pdu_tx_retry; - u8_t is_crc_backoff = 0; - u8_t is_rx_enqueue = 0; - u8_t is_ull_rx = 0; + u8_t is_crc_backoff = 0U; + u8_t is_rx_enqueue = 0U; + u8_t is_ull_rx = 0U; u8_t rssi_ready; u8_t trx_done; u8_t is_done; @@ -161,7 +161,7 @@ void lll_conn_isr_rx(void *param) crc_ok = radio_crc_is_valid(); rssi_ready = radio_rssi_is_ready(); } else { - crc_ok = rssi_ready = 0; + crc_ok = rssi_ready = 0U; } /* Clear radio status and events */ @@ -197,19 +197,19 @@ void lll_conn_isr_rx(void *param) } /* Reset CRC expiry counter */ - crc_expire = 0; + crc_expire = 0U; /* CRC valid flag used to detect supervision timeout */ - crc_valid = 1; + crc_valid = 1U; } else { /* Start CRC error countdown, if not already started */ - if (crc_expire == 0) { - crc_expire = 2; + if (crc_expire == 0U) { + crc_expire = 2U; } /* CRC error countdown */ crc_expire--; - is_crc_backoff = (crc_expire == 0); + is_crc_backoff = (crc_expire == 0U); } /* prepare tx packet */ @@ -315,7 +315,7 @@ lll_conn_isr_rx_exit: MFIFO_ENQUEUE(conn_ack, idx); - is_ull_rx = 1; + is_ull_rx = 1U; } if (is_rx_enqueue) { @@ -327,7 +327,7 @@ lll_conn_isr_rx_exit: node_rx->hdr.handle = lll->handle; ull_rx_put(node_rx->hdr.link, node_rx); - is_ull_rx = 1; + is_ull_rx = 1U; } if (is_ull_rx) { @@ -453,7 +453,7 @@ void lll_conn_rx_pkt_set(struct lll_conn *lll) #if defined(CONFIG_BT_CTLR_PHY) phy = lll->phy_rx; #else /* !CONFIG_BT_CTLR_PHY */ - phy = 0; + phy = 0U; #endif /* !CONFIG_BT_CTLR_PHY */ radio_phy_set(phy, 0); @@ -488,8 +488,8 @@ void lll_conn_tx_pkt_set(struct lll_conn *lll, struct pdu_data *pdu_data_tx) phy = lll->phy_tx; flags = lll->phy_flags; #else /* !CONFIG_BT_CTLR_PHY */ - phy = 0; - flags = 0; + phy = 0U; + flags = 0U; #endif /* !CONFIG_BT_CTLR_PHY */ radio_phy_set(phy, flags); @@ -497,7 +497,8 @@ void lll_conn_tx_pkt_set(struct lll_conn *lll, struct pdu_data *pdu_data_tx) if (0) { #if defined(CONFIG_BT_CTLR_LE_ENC) } else if (lll->enc_tx) { - radio_pkt_configure(8, (max_tx_octets + 4), (phy << 1) | 0x01); + radio_pkt_configure(8, (max_tx_octets + 4U), + (phy << 1) | 0x01); radio_pkt_tx_set(radio_ccm_tx_pkt_set(&lll->ccm_tx, pdu_data_tx)); @@ -589,7 +590,7 @@ void lll_conn_pdu_tx_prep(struct lll_conn *lll, struct pdu_data **pdu_data_tx) #if defined(CONFIG_BT_CTLR_LE_ENC) if (lll->enc_tx) { /* deduct the MIC */ - max_tx_octets -= 4; + max_tx_octets -= 4U; } #endif /* CONFIG_BT_CTLR_LE_ENC */ @@ -801,7 +802,7 @@ static int isr_rx_pdu(struct lll_conn *lll, struct pdu_data *pdu_data_rx, pdu_data_tx_len = pdu_data_tx->len; #if defined(CONFIG_BT_CTLR_LE_ENC) - if (pdu_data_tx_len != 0) { + if (pdu_data_tx_len != 0U) { /* if encrypted increment tx counter */ if (lll->enc_tx) { lll->ccm_tx.counter++; @@ -863,7 +864,7 @@ static int isr_rx_pdu(struct lll_conn *lll, struct pdu_data *pdu_data_rx, #endif /* CONFIG_BT_CTLR_LE_ENC */ /* Enqueue non-empty PDU */ - *is_rx_enqueue = 1; + *is_rx_enqueue = 1U; } } diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_filter.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_filter.c index 5753a565de6..8807a70bccb 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_filter.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_filter.c @@ -157,7 +157,7 @@ static u32_t filter_remove(struct ll_filter *filter, u8_t addr_type, static void wl_clear(void) { for (int i = 0; i < WL_SIZE; i++) { - wl[i].taken = 0; + wl[i].taken = 0U; } } @@ -201,11 +201,11 @@ static u32_t wl_add(bt_addr_le_t *id_addr) j = ll_rl_find(id_addr->type, id_addr->a.val, NULL); if (j < ARRAY_SIZE(rl)) { wl[i].rl_idx = j; - rl[j].wl = 1; + rl[j].wl = 1U; } else { wl[i].rl_idx = FILTER_IDX_NONE; } - wl[i].taken = 1; + wl[i].taken = 1U; return 0; } @@ -219,9 +219,9 @@ static u32_t wl_remove(bt_addr_le_t *id_addr) u8_t j = wl[i].rl_idx; if (j < ARRAY_SIZE(rl)) { - rl[j].wl = 0; + rl[j].wl = 0U; } - wl[i].taken = 0; + wl[i].taken = 0U; return 0; } @@ -323,7 +323,7 @@ u8_t ll_wl_clear(void) filter_clear(&wl_filter); #endif /* CONFIG_BT_CTLR_PRIVACY */ - wl_anon = 0; + wl_anon = 0U; return 0; } @@ -343,7 +343,7 @@ u8_t ll_wl_add(bt_addr_le_t *addr) #endif /* CONFIG_BT_OBSERVER */ if (addr->type == ADDR_TYPE_ANON) { - wl_anon = 1; + wl_anon = 1U; return 0; } @@ -369,7 +369,7 @@ u8_t ll_wl_remove(bt_addr_le_t *addr) #endif /* CONFIG_BT_OBSERVER */ if (addr->type == ADDR_TYPE_ANON) { - wl_anon = 0; + wl_anon = 0U; return 0; } @@ -386,7 +386,7 @@ static void filter_wl_update(void) u8_t i; /* Populate filter from wl peers */ - for (i = 0; i < WL_SIZE; i++) { + for (i = 0U; i < WL_SIZE; i++) { u8_t j; if (!wl[i].taken) { @@ -408,7 +408,7 @@ static void filter_rl_update(void) u8_t i; /* Populate filter from rl peers */ - for (i = 0; i < CONFIG_BT_CTLR_RL_SIZE; i++) { + for (i = 0U; i < CONFIG_BT_CTLR_RL_SIZE; i++) { if (rl[i].taken) { filter_insert(&rl_filter, i, rl[i].id_addr_type, rl[i].id_addr.val); @@ -464,7 +464,7 @@ u8_t ll_rl_find(u8_t id_addr_type, u8_t *id_addr, u8_t *free) *free = FILTER_IDX_NONE; } - for (i = 0; i < CONFIG_BT_CTLR_RL_SIZE; i++) { + for (i = 0U; i < CONFIG_BT_CTLR_RL_SIZE; i++) { if (LIST_MATCH(rl, i, id_addr_type, id_addr)) { return i; } else if (free && !rl[i].taken && (*free == FILTER_IDX_NONE)) { @@ -510,11 +510,11 @@ bool ctrl_rl_addr_allowed(u8_t id_addr_type, u8_t *id_addr, u8_t *rl_idx) return true; } - for (i = 0; i < CONFIG_BT_CTLR_RL_SIZE; i++) { + for (i = 0U; i < CONFIG_BT_CTLR_RL_SIZE; i++) { if (rl[i].taken && (rl[i].id_addr_type == id_addr_type)) { u8_t *addr = rl[i].id_addr.val; - for (j = 0; j < BDADDR_SIZE; j++) { + for (j = 0U; j < BDADDR_SIZE; j++) { if (addr[j] != id_addr[j]) { break; } @@ -537,7 +537,7 @@ bool ctrl_rl_addr_resolve(u8_t id_addr_type, u8_t *id_addr, u8_t rl_idx) return false; } - if ((id_addr_type != 0) && ((id_addr[5] & 0xc0) == 0x40)) { + if ((id_addr_type != 0U) && ((id_addr[5] & 0xc0) == 0x40)) { return bt_rpa_irk_matches(rl[rl_idx].local_irk, (bt_addr_t *)id_addr); } @@ -601,7 +601,7 @@ static void rpa_adv_refresh(struct ll_adv_set *adv) if (radio_adv_data->first == radio_adv_data->last) { last = radio_adv_data->last + 1; if (last == DOUBLE_BUFFER_SIZE) { - last = 0; + last = 0U; } } else { last = radio_adv_data->last; @@ -634,10 +634,10 @@ static void rpa_adv_refresh(struct ll_adv_set *adv) static void rl_clear(void) { for (u8_t i = 0; i < CONFIG_BT_CTLR_RL_SIZE; i++) { - rl[i].taken = 0; + rl[i].taken = 0U; } - peer_irk_count = 0; + peer_irk_count = 0U; } static int rl_access_check(bool check_ar) @@ -662,7 +662,7 @@ void ll_rl_rpa_update(bool timeout) (now - rpa_last_ms >= rpa_timeout_ms); BT_DBG(""); - for (i = 0; i < CONFIG_BT_CTLR_RL_SIZE; i++) { + for (i = 0U; i < CONFIG_BT_CTLR_RL_SIZE; i++) { if ((rl[i].taken) && (all || !rl[i].rpas_ready)) { if (rl[i].pirk) { @@ -689,7 +689,7 @@ void ll_rl_rpa_update(bool timeout) rl[i].local_rpa = &local_rpas[i]; } - rl[i].rpas_ready = 1; + rl[i].rpas_ready = 1U; } } @@ -797,18 +797,18 @@ u32_t ll_rl_add(bt_addr_le_t *id_addr, const u8_t pirk[16], rl[i].local_rpa = NULL; } memset(rl[i].curr_rpa.val, 0x00, sizeof(rl[i].curr_rpa)); - rl[i].rpas_ready = 0; + rl[i].rpas_ready = 0U; /* Default to Network Privacy */ - rl[i].dev = 0; + rl[i].dev = 0U; /* Add reference to a whitelist entry */ j = wl_find(id_addr->type, id_addr->a.val, NULL); if (j < ARRAY_SIZE(wl)) { wl[j].rl_idx = i; - rl[i].wl = 1; + rl[i].wl = 1U; } else { - rl[i].wl = 0; + rl[i].wl = 0U; } - rl[i].taken = 1; + rl[i].taken = 1U; return 0; } @@ -832,7 +832,7 @@ u32_t ll_rl_remove(bt_addr_le_t *id_addr) if (pj && pi != pj) { memcpy(peer_irks[pi], peer_irks[pj], 16); - for (k = 0; + for (k = 0U; k < CONFIG_BT_CTLR_RL_SIZE; k++) { @@ -852,7 +852,7 @@ u32_t ll_rl_remove(bt_addr_le_t *id_addr) if (j < ARRAY_SIZE(wl)) { wl[j].rl_idx = FILTER_IDX_NONE; } - rl[i].taken = 0; + rl[i].taken = 0U; return 0; } @@ -912,10 +912,10 @@ u32_t ll_rl_enable(u8_t enable) switch (enable) { case BT_HCI_ADDR_RES_DISABLE: - rl_enable = 0; + rl_enable = 0U; break; case BT_HCI_ADDR_RES_ENABLE: - rl_enable = 1; + rl_enable = 1U; break; default: return BT_HCI_ERR_INVALID_PARAM; @@ -926,7 +926,7 @@ u32_t ll_rl_enable(u8_t enable) void ll_rl_timeout_set(u16_t timeout) { - rpa_timeout_ms = timeout * 1000; + rpa_timeout_ms = timeout * 1000U; } u32_t ll_priv_mode_set(bt_addr_le_t *id_addr, u8_t mode) @@ -942,10 +942,10 @@ u32_t ll_priv_mode_set(bt_addr_le_t *id_addr, u8_t mode) if (i < ARRAY_SIZE(rl)) { switch (mode) { case BT_HCI_LE_PRIVACY_MODE_NETWORK: - rl[i].dev = 0; + rl[i].dev = 0U; break; case BT_HCI_LE_PRIVACY_MODE_DEVICE: - rl[i].dev = 1; + rl[i].dev = 1U; break; default: return BT_HCI_ERR_INVALID_PARAM; @@ -961,12 +961,12 @@ u32_t ll_priv_mode_set(bt_addr_le_t *id_addr, u8_t mode) void ll_filter_reset(bool init) { - wl_anon = 0; + wl_anon = 0U; #if defined(CONFIG_BT_CTLR_PRIVACY) wl_clear(); - rl_enable = 0; + rl_enable = 0U; rpa_timeout_ms = DEFAULT_RPA_TIMEOUT_MS; rpa_last_ms = -1; rl_clear(); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_prof.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_prof.c index 7b036f10372..70a808d91e2 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_prof.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_prof.c @@ -60,7 +60,7 @@ void lll_prof_cputime_capture(void) void lll_prof_send(void) { u8_t latency, cputime, prev; - u8_t chg = 0; + u8_t chg = 0U; /* calculate the elapsed time in us since on-air radio packet end * to ISR entry @@ -74,18 +74,18 @@ void lll_prof_send(void) /* check changes in min, avg and max of latency */ if (latency > latency_max) { latency_max = latency; - chg = 1; + chg = 1U; } if (latency < latency_min) { latency_min = latency; - chg = 1; + chg = 1U; } /* check for +/- 1us change */ prev = ((u16_t)latency_prev + latency) >> 1; if (prev != latency_prev) { latency_prev = latency; - chg = 1; + chg = 1U; } /* calculate the elapsed time in us since ISR entry */ @@ -94,19 +94,19 @@ void lll_prof_send(void) /* check changes in min, avg and max */ if (cputime > cputime_max) { cputime_max = cputime; - chg = 1; + chg = 1U; } if (cputime < cputime_min) { cputime_min = cputime; - chg = 1; + chg = 1U; } /* check for +/- 1us change */ prev = ((u16_t)cputime_prev + cputime) >> 1; if (prev != cputime_prev) { cputime_prev = cputime; - chg = 1; + chg = 1U; } /* generate event if any change */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c index f6f14efc49a..66cf484aaa4 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c @@ -291,8 +291,8 @@ static int is_abort_cb(void *next, int prio, void *curr, radio_isr_set(isr_done, lll); radio_disable(); - if (++lll->chan == 3) { - lll->chan = 0; + if (++lll->chan == 3U) { + lll->chan = 0U; } lll_chan_set(37 + lll->chan); @@ -363,7 +363,7 @@ static void isr_rx(void *param) irkmatch_id = radio_ar_match_get(); rssi_ready = radio_rssi_is_ready(); } else { - crc_ok = devmatch_ok = irkmatch_ok = rssi_ready = 0; + crc_ok = devmatch_ok = irkmatch_ok = rssi_ready = 0U; devmatch_id = irkmatch_id = 0xFF; } @@ -545,8 +545,8 @@ static void isr_cleanup(void *param) radio_filter_disable(); - if (++lll->chan == 3) { - lll->chan = 0; + if (++lll->chan == 3U) { + lll->chan = 0U; } #if defined(CONFIG_BT_HCI_MESH_EXT) @@ -595,7 +595,7 @@ static inline bool isr_rx_scan_check(struct lll_scan *lll, u8_t irkmatch_ok, (((_radio.scanner.filter_policy & 0x01) != 0) && (devmatch_ok || ctrl_irk_whitelisted(rl_idx))); #else - return ((lll->filter_policy & 0x01) == 0) || + return ((lll->filter_policy & 0x01) == 0U) || devmatch_ok; #endif /* CONFIG_BT_CTLR_PRIVACY */ } @@ -647,7 +647,7 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok, u32_t scan_interval_us; /* FIXME: is this correct for continuous scanning? */ - scan_interval_us = lll->interval * 625; + scan_interval_us = lll->interval * 625U; pdu_end_us %= scan_interval_us; } evt = HDR_LLL2EVT(lll); @@ -697,11 +697,11 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok, &lll_conn->crc_init[0], 3); pdu_tx->connect_ind.win_size = 1; - conn_interval_us = (u32_t)lll_conn->interval * 1250; + conn_interval_us = (u32_t)lll_conn->interval * 1250U; conn_offset_us = radio_tmr_end_get() + 502 + 1250; if (!IS_ENABLED(CONFIG_BT_CTLR_SCHED_ADVANCED) || - lll->conn_win_offset_us == 0) { + lll->conn_win_offset_us == 0U) { conn_space_us = conn_offset_us; pdu_tx->connect_ind.win_offset = sys_cpu_to_le16(0); } else { @@ -712,7 +712,7 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok, } pdu_tx->connect_ind.win_offset = sys_cpu_to_le16((conn_space_us - - conn_offset_us) / 1250); + conn_offset_us) / 1250U); pdu_tx->connect_ind.win_size++; } @@ -834,7 +834,7 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok, &pdu_adv_rx->adv_ind.addr[0], BDADDR_SIZE); /* switch scanner state to active */ - lll->state = 1; + lll->state = 1U; radio_isr_set(isr_tx, lll); radio_tmr_tifs_set(TIFS_US); @@ -883,7 +883,7 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok, #endif /* CONFIG_BT_CTLR_ADV_EXT */ ((pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_RSP) && (pdu_adv_rx->len <= sizeof(struct pdu_adv_scan_rsp)) && - (lll->state != 0) && + (lll->state != 0U) && isr_scan_rsp_adva_matches(pdu_adv_rx))) && (pdu_adv_rx->len != 0) && #if defined(CONFIG_BT_CENTRAL) @@ -914,7 +914,7 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok, static inline bool isr_scan_init_check(struct lll_scan *lll, struct pdu_adv *pdu, u8_t rl_idx) { - return ((((lll->filter_policy & 0x01) != 0) || + return ((((lll->filter_policy & 0x01) != 0U) || isr_scan_init_adva_check(lll, pdu, rl_idx)) && (((pdu->type == PDU_ADV_TYPE_ADV_IND) && (pdu->len <= sizeof(struct pdu_adv_adv_ind))) || @@ -966,7 +966,7 @@ static inline bool isr_scan_tgta_rpa_check(struct lll_scan *lll, struct pdu_adv *pdu, bool *dir_report) { - if (((lll->filter_policy & 0x02) != 0) && + if (((lll->filter_policy & 0x02) != 0U) && (pdu->rx_addr != 0) && ((pdu->direct_ind.tgt_addr[5] & 0xc0) == 0x40)) { diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c index 38654c5cbfb..268eb1af9aa 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c @@ -94,7 +94,7 @@ static void isr_tx(void *param) #endif /* CONFIG_BT_CTLR_GPIO_PA_PIN */ /* Exit if radio disabled */ - if (((tx_req - tx_ack) & 0x01) == 0) { + if (((tx_req - tx_ack) & 0x01) == 0U) { tx_ack = tx_req; return; @@ -102,7 +102,7 @@ static void isr_tx(void *param) /* LE Test Packet Interval */ l = radio_tmr_end_get() - radio_tmr_ready_get(); - i = ((l + 249 + 624) / 625) * 625; + i = ((l + 249 + 624) / 625) * 625U; t = radio_tmr_end_get() - l + i; t -= radio_tx_ready_delay_get(test_phy, test_phy_flags); @@ -110,7 +110,7 @@ static void isr_tx(void *param) radio_tmr_sample(); s = radio_tmr_sample_get(); while (t < s) { - t += 625; + t += 625U; } /* Setup next Tx */ @@ -131,7 +131,7 @@ static void isr_tx(void *param) static void isr_rx(void *param) { - u8_t crc_ok = 0; + u8_t crc_ok = 0U; u8_t trx_done; /* Read radio status and events */ @@ -179,10 +179,10 @@ static u32_t init(u8_t chan, u8_t phy, void (*isr)(void *)) /* Store value needed in Tx/Rx ISR */ if (phy < 0x04) { test_phy = BIT(phy - 1); - test_phy_flags = 1; + test_phy_flags = 1U; } else { test_phy = BIT(2); - test_phy_flags = 0; + test_phy_flags = 0U; } /* Setup Radio in Tx/Rx */ @@ -314,7 +314,7 @@ u32_t ll_test_end(u16_t *num_rx) /* Return packets Rx-ed/Completed */ *num_rx = test_num_rx; - test_num_rx = 0; + test_num_rx = 0U; /* Disable Radio, if in Rx test */ ack = tx_ack; diff --git a/subsys/bluetooth/controller/ll_sw/ull.c b/subsys/bluetooth/controller/ll_sw/ull.c index fbe581c266a..a9c666bf73a 100644 --- a/subsys/bluetooth/controller/ll_sw/ull.c +++ b/subsys/bluetooth/controller/ll_sw/ull.c @@ -328,7 +328,7 @@ void ll_reset(void) scan = ull_scan_is_enabled_get(0); LL_ASSERT(scan); - scan->is_enabled = 0; + scan->is_enabled = 0U; scan->lll.conn = NULL; } @@ -372,7 +372,7 @@ u8_t ll_rx_get(void **node_rx, u16_t *handle) { struct node_rx_hdr *rx; memq_link_t *link; - u8_t cmplt = 0; + u8_t cmplt = 0U; #if defined(CONFIG_BT_CONN) ll_rx_get_again: @@ -386,13 +386,13 @@ ll_rx_get_again: u8_t f, cmplt_prev, cmplt_curr; u16_t h; - cmplt_curr = 0; + cmplt_curr = 0U; f = mfifo_tx_ack.f; do { cmplt_prev = cmplt_curr; cmplt_curr = tx_cmplt_get(&h, &f, mfifo_tx_ack.l); - } while ((cmplt_prev != 0) || + } while ((cmplt_prev != 0U) || (cmplt_prev != cmplt_curr)); /* Do not send up buffers to Host thread that are @@ -597,14 +597,14 @@ void ll_rx_dequeue(void) } } - adv->is_enabled = 0; + adv->is_enabled = 0U; #endif /* CONFIG_BT_PERIPHERAL */ #if defined(CONFIG_BT_CENTRAL) } else { struct lll_scan *lll = ftr->param; struct ll_scan_set *scan = (void *)HDR_LLL2EVT(lll); - scan->is_enabled = 0; + scan->is_enabled = 0U; #endif /* CONFIG_BT_CENTRAL */ } @@ -627,12 +627,12 @@ void ll_rx_dequeue(void) adv = ull_adv_is_enabled_get(0); LL_ASSERT(adv); - adv->is_enabled = 0; + adv->is_enabled = 0U; scan = ull_scan_is_enabled_get(0); LL_ASSERT(scan); - scan->is_enabled = 0; + scan->is_enabled = 0U; ll_adv_scan_state_cb(0); #endif /* CONFIG_BT_HCI_MESH_EXT */ @@ -679,7 +679,7 @@ void ll_rx_mem_release(void **node_rx) conn = (void *)HDR_LLL2EVT(conn_lll); ll_conn_release(conn); - scan->is_enabled = 0; + scan->is_enabled = 0U; scan->lll.conn = NULL; @@ -1016,7 +1016,7 @@ int ull_prepare_enqueue(lll_is_abort_cb_t is_abort_cb, e->abort_cb = abort_cb; e->prio = prio; e->is_resume = is_resume; - e->is_aborted = 0; + e->is_aborted = 0U; MFIFO_ENQUEUE(prep, idx); @@ -1240,7 +1240,7 @@ static u8_t tx_cmplt_get(u16_t *handle, u8_t *first, u8_t last) } *handle = tx->handle; - cmplt = 0; + cmplt = 0U; do { struct node_tx *node_tx; struct pdu_data *p; @@ -1480,7 +1480,7 @@ static inline void rx_demux_event_done(memq_link_t *link, } /* release done */ - done->extra.type = 0; + done->extra.type = 0U; done_release(link, done); /* dequeue prepare pipeline */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv.c b/subsys/bluetooth/controller/ll_sw/ull_adv.c index 214ed92a99b..a719dbf4576 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv.c @@ -350,12 +350,12 @@ u8_t ll_adv_data_set(u8_t len, u8_t const *const data) /* update adv pdu fields. */ pdu = lll_adv_data_alloc(&adv->lll, &idx); pdu->type = prev->type; - pdu->rfu = 0; + pdu->rfu = 0U; if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) { pdu->chan_sel = prev->chan_sel; } else { - pdu->chan_sel = 0; + pdu->chan_sel = 0U; } pdu->tx_addr = prev->tx_addr; @@ -827,7 +827,7 @@ int ull_adv_reset(void) u16_t handle; int err; - for (handle = 0; handle < BT_CTLR_ADV_MAX; handle++) { + for (handle = 0U; handle < BT_CTLR_ADV_MAX; handle++) { (void)disable(handle); } @@ -947,13 +947,13 @@ static void ticker_cb(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, ull_entropy_get(sizeof(random_delay), &random_delay); random_delay %= 10; - random_delay += 1; + random_delay += 1U; ret = ticker_update(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH, (TICKER_ID_ADV_BASE + ull_adv_handle_get(adv)), - HAL_TICKER_US_TO_TICKS(random_delay * 1000), + HAL_TICKER_US_TO_TICKS(random_delay * 1000U), 0, 0, 0, 0, 0, ticker_op_update_cb, adv); LL_ASSERT((ret == TICKER_STATUS_SUCCESS) || @@ -1129,7 +1129,7 @@ static inline u8_t disable(u16_t handle) } #endif /* CONFIG_BT_PERIPHERAL */ - adv->is_enabled = 0; + adv->is_enabled = 0U; #if defined(CONFIG_BT_CTLR_PRIVACY) if (!ull_scan_is_enabled_get(0)) { diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index 6099d9e4d5f..e1144c99556 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -188,7 +188,7 @@ u8_t ull_conn_allowed_check(void *conn) } conn_hdr->llcp_req++; - if (((conn_hdr->llcp_req - conn_hdr->llcp_ack) & 0x03) != 1) { + if (((conn_hdr->llcp_req - conn_hdr->llcp_ack) & 0x03) != 1U) { conn_hdr->llcp_req--; return BT_HCI_ERR_CMD_DISALLOWED; } @@ -265,14 +265,14 @@ u8_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status, u16_t interval_min, return ret; } - conn->llcp.conn_upd.win_size = 1; - conn->llcp.conn_upd.win_offset_us = 0; + conn->llcp.conn_upd.win_size = 1U; + conn->llcp.conn_upd.win_offset_us = 0U; conn->llcp.conn_upd.interval = interval_max; conn->llcp.conn_upd.latency = latency; conn->llcp.conn_upd.timeout = timeout; /* conn->llcp.conn_upd.instant = 0; */ conn->llcp.conn_upd.state = LLCP_CUI_STATE_USE; - conn->llcp.conn_upd.is_internal = 0; + conn->llcp.conn_upd.is_internal = 0U; conn->llcp_type = LLCP_CONN_UPD; conn->llcp_req++; @@ -290,20 +290,20 @@ u8_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status, u16_t interval_min, conn->llcp_conn_param.status = status; conn->llcp_conn_param.state = cmd; - conn->llcp_conn_param.cmd = 1; + conn->llcp_conn_param.cmd = 1U; } else { if (conn->llcp_conn_param.req != conn->llcp_conn_param.ack) { return BT_HCI_ERR_CMD_DISALLOWED; } - conn->llcp_conn_param.status = 0; + conn->llcp_conn_param.status = 0U; conn->llcp_conn_param.interval_min = interval_min; conn->llcp_conn_param.interval_max = interval_max; conn->llcp_conn_param.latency = latency; conn->llcp_conn_param.timeout = timeout; conn->llcp_conn_param.state = cmd; - conn->llcp_conn_param.cmd = 1; + conn->llcp_conn_param.cmd = 1U; conn->llcp_conn_param.req++; } @@ -329,7 +329,7 @@ u8_t ll_chm_get(u16_t handle, u8_t *chm) * we were reading it from memory. */ do { - conn->chm_updated = 0; + conn->chm_updated = 0U; memcpy(chm, conn->lll.data_chan_map, sizeof(conn->lll.data_chan_map)); } while (conn->chm_updated); @@ -437,7 +437,7 @@ u8_t ll_phy_req_send(u16_t handle, u8_t tx, u8_t flags, u8_t rx) } conn->llcp_phy.state = LLCP_PHY_STATE_REQ; - conn->llcp_phy.cmd = 1; + conn->llcp_phy.cmd = 1U; conn->llcp_phy.tx = tx; conn->llcp_phy.flags = flags; conn->llcp_phy.rx = rx; @@ -473,7 +473,7 @@ u8_t ll_apto_get(u16_t handle, u16_t *apto) return BT_HCI_ERR_UNKNOWN_CONN_ID; } - *apto = conn->apto_reload * conn->lll.interval * 125 / 1000; + *apto = conn->apto_reload * conn->lll.interval * 125U / 1000; return 0; } @@ -487,7 +487,7 @@ u8_t ll_apto_set(u16_t handle, u16_t apto) return BT_HCI_ERR_UNKNOWN_CONN_ID; } - conn->apto_reload = RADIO_CONN_EVENTS(apto * 10 * 1000, + conn->apto_reload = RADIO_CONN_EVENTS(apto * 10U * 1000U, conn->lll.interval * 1250); return 0; @@ -516,7 +516,7 @@ int ull_conn_reset(void) u16_t handle; int err; - for (handle = 0; handle < CONFIG_BT_MAX_CONN; handle++) { + for (handle = 0U; handle < CONFIG_BT_MAX_CONN; handle++) { disable(handle); } @@ -806,7 +806,7 @@ int ull_conn_llcp(struct ll_conn *conn, u32_t ticks_at_expire, u16_t lazy) /* NOTE: if supervision timeout equals connection * interval, dont timeout in current event. */ - if (conn->procedure_expire <= 1) { + if (conn->procedure_expire <= 1U) { conn->procedure_expire++; } } @@ -848,11 +848,11 @@ void ull_conn_done(struct node_rx_event_done *done) conn->apto_reload; if (conn->appto_reload != appto_reload_new) { conn->appto_reload = appto_reload_new; - conn->apto_expire = 0; + conn->apto_expire = 0U; } /* start authenticated payload (pre) timeout */ - if (conn->apto_expire == 0) { + if (conn->apto_expire == 0U) { conn->appto_expire = conn->appto_reload; conn->apto_expire = conn->apto_reload; } @@ -862,7 +862,7 @@ void ull_conn_done(struct node_rx_event_done *done) case LLL_CONN_MIC_PASS: #if defined(CONFIG_BT_CTLR_LE_PING) - conn->appto_expire = conn->apto_expire = 0; + conn->appto_expire = conn->apto_expire = 0U; #endif /* CONFIG_BT_CTLR_LE_PING */ break; @@ -885,8 +885,8 @@ void ull_conn_done(struct node_rx_event_done *done) } /* Slave drift compensation calc or master terminate acked */ - ticks_drift_plus = 0; - ticks_drift_minus = 0; + ticks_drift_plus = 0U; + ticks_drift_minus = 0U; if (done->extra.trx_cnt) { if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && lll->role) { ull_slave_done(done, &ticks_drift_plus, @@ -896,7 +896,7 @@ void ull_conn_done(struct node_rx_event_done *done) } /* Reset connection failed to establish countdown */ - conn->connect_expire = 0; + conn->connect_expire = 0U; } /* Events elapsed used in timeout checks below */ @@ -905,7 +905,7 @@ void ull_conn_done(struct node_rx_event_done *done) /* Reset supervision countdown */ if (done->extra.crc_valid) { - conn->supervision_expire = 0; + conn->supervision_expire = 0U; } /* check connection failed to establish */ @@ -932,7 +932,7 @@ void ull_conn_done(struct node_rx_event_done *done) } /* check supervision timeout */ - force = 0; + force = 0U; if (conn->supervision_expire) { if (conn->supervision_expire > elapsed_event) { conn->supervision_expire -= elapsed_event; @@ -943,15 +943,15 @@ void ull_conn_done(struct node_rx_event_done *done) /* Force both master and slave when close to * supervision timeout. */ - if (conn->supervision_expire <= 6) { - force = 1; + if (conn->supervision_expire <= 6U) { + force = 1U; } /* use randomness to force slave role when anchor * points are being missed. */ else if (lll->role) { if (latency_event) { - force = 1; + force = 1U; } else { /* FIXME:*/ #if 0 @@ -975,7 +975,7 @@ void ull_conn_done(struct node_rx_event_done *done) } /* check procedure timeout */ - if (conn->procedure_expire != 0) { + if (conn->procedure_expire != 0U) { if (conn->procedure_expire > elapsed_event) { conn->procedure_expire -= elapsed_event; } else { @@ -989,7 +989,7 @@ void ull_conn_done(struct node_rx_event_done *done) #if defined(CONFIG_BT_CTLR_LE_PING) /* check apto */ - if (conn->apto_expire != 0) { + if (conn->apto_expire != 0U) { if (conn->apto_expire > elapsed_event) { conn->apto_expire -= elapsed_event; } else { @@ -997,7 +997,7 @@ void ull_conn_done(struct node_rx_event_done *done) rx = ll_pdu_rx_alloc(); if (rx) { - conn->apto_expire = 0; + conn->apto_expire = 0U; rx->handle = lll->handle; rx->type = NODE_RX_TYPE_APTO; @@ -1006,22 +1006,22 @@ void ull_conn_done(struct node_rx_event_done *done) ll_rx_put(rx->link, rx); ll_rx_sched(); } else { - conn->apto_expire = 1; + conn->apto_expire = 1U; } } } /* check appto */ - if (conn->appto_expire != 0) { + if (conn->appto_expire != 0U) { if (conn->appto_expire > elapsed_event) { conn->appto_expire -= elapsed_event; } else { - conn->appto_expire = 0; + conn->appto_expire = 0U; - if ((conn->procedure_expire == 0) && + if ((conn->procedure_expire == 0U) && (conn->llcp_req == conn->llcp_ack)) { conn->llcp_type = LLCP_PING; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; } } } @@ -1061,14 +1061,14 @@ void ull_conn_done(struct node_rx_event_done *done) } /* check if latency needs update */ - lazy = 0; + lazy = 0U; if ((force) || (latency_event != lll->latency_event)) { lazy = lll->latency_event + 1; } /* update conn ticker */ - if ((ticks_drift_plus != 0) || (ticks_drift_minus != 0) || - (lazy != 0) || (force != 0)) { + if ((ticks_drift_plus != 0U) || (ticks_drift_minus != 0U) || + (lazy != 0U) || (force != 0U)) { u8_t ticker_id = TICKER_ID_CONN_BASE + lll->handle; struct ll_conn *conn = lll->hdr.parent; u32_t ticker_status; @@ -1434,7 +1434,7 @@ static inline void event_conn_upd_init(struct ll_conn *conn, pdu_ctrl_tx->llctrl.conn_update_ind.win_size = conn->llcp.conn_upd.win_size; pdu_ctrl_tx->llctrl.conn_update_ind.win_offset = - sys_cpu_to_le16(conn->llcp.conn_upd.win_offset_us / 1250); + sys_cpu_to_le16(conn->llcp.conn_upd.win_offset_us / 1250U); pdu_ctrl_tx->llctrl.conn_update_ind.interval = sys_cpu_to_le16(conn->llcp.conn_upd.interval); pdu_ctrl_tx->llctrl.conn_update_ind.latency = @@ -1577,7 +1577,7 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, conn->llcp_conn_param.ack = conn->llcp_conn_param.req; /* Stop procedure timeout */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; } #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */ @@ -1597,7 +1597,7 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, /* Prepare the rx packet structure */ if ((conn->llcp.conn_upd.interval != lll->interval) || (conn->llcp.conn_upd.latency != lll->latency) || - (RADIO_CONN_EVENTS(conn->llcp.conn_upd.timeout * 10000, + (RADIO_CONN_EVENTS(conn->llcp.conn_upd.timeout * 10000U, lll->interval * 1250) != conn->supervision_reload)) { struct node_rx_cu *cu; @@ -1641,17 +1641,17 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, conn->llcp.conn_upd.interval; if (conn_interval_new > conn_interval_old) { ticks_at_expire += HAL_TICKER_US_TO_TICKS( - (conn_interval_new - conn_interval_old) * 1250); + (conn_interval_new - conn_interval_old) * 1250U); } else { ticks_at_expire -= HAL_TICKER_US_TO_TICKS( - (conn_interval_old - conn_interval_new) * 1250); + (conn_interval_old - conn_interval_new) * 1250U); } lll->latency_prepare -= (instant_latency - latency); /* calculate the offset, window widening and interval */ ticks_slot_offset = MAX(conn->evt.ticks_active_to_start, conn->evt.ticks_xtal_to_start); - conn_interval_us = conn->llcp.conn_upd.interval * 1250; + conn_interval_us = conn->llcp.conn_upd.interval * 1250U; periodic_us = conn_interval_us; if (lll->role) { lll->slave.window_widening_prepare_us -= @@ -1661,12 +1661,12 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, lll->slave.window_widening_periodic_us = (((lll_conn_ppm_local_get() + lll_conn_ppm_get(lll->slave.sca)) * - conn_interval_us) + (1000000 - 1)) / 1000000; + conn_interval_us) + (1000000 - 1)) / 1000000U; lll->slave.window_widening_max_us = (conn_interval_us >> 1) - TIFS_US; lll->slave.window_size_prepare_us = - conn->llcp.conn_upd.win_size * 1250; - conn->slave.ticks_to_offset = 0; + conn->llcp.conn_upd.win_size * 1250U; + conn->slave.ticks_to_offset = 0U; lll->slave.window_widening_prepare_us += lll->slave.window_widening_periodic_us * @@ -1681,8 +1681,8 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, lll->slave.window_widening_periodic_us * latency); ticks_win_offset = HAL_TICKER_US_TO_TICKS( - (conn->llcp.conn_upd.win_offset_us / 1250) * - 1250); + (conn->llcp.conn_upd.win_offset_us / 1250U) * + 1250U); periodic_us -= lll->slave.window_widening_periodic_us; } else { ticks_win_offset = HAL_TICKER_US_TO_TICKS( @@ -1692,13 +1692,13 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, * ticker_start function for first interval; add a * tick so as to use the ceiled value. */ - ticks_win_offset += 1; + ticks_win_offset += 1U; } lll->interval = conn->llcp.conn_upd.interval; lll->latency = conn->llcp.conn_upd.latency; conn->supervision_reload = RADIO_CONN_EVENTS((conn->llcp.conn_upd.timeout - * 10 * 1000), conn_interval_us); + * 10U * 1000U), conn_interval_us); conn->procedure_reload = RADIO_CONN_EVENTS((40 * 1000 * 1000), conn_interval_us); @@ -1716,7 +1716,7 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, #endif /* CONFIG_BT_CTLR_LE_PING */ if (!conn->llcp.conn_upd.is_internal) { - conn->supervision_expire = 0; + conn->supervision_expire = 0U; } /* disable ticker job, in order to chain stop and start @@ -1779,7 +1779,7 @@ static inline void event_ch_map_prep(struct ll_conn *conn, struct pdu_data *pdu_ctrl_tx = (void *)tx->pdu; /* reset initiate flag */ - conn->llcp.chan_map.initiate = 0; + conn->llcp.chan_map.initiate = 0U; /* set instant */ conn->llcp.chan_map.instant = event_counter + @@ -1816,7 +1816,7 @@ static inline void event_ch_map_prep(struct ll_conn *conn, lll->data_chan_count = util_ones_count_get(&lll->data_chan_map[0], sizeof(lll->data_chan_map)); - conn->chm_updated = 1; + conn->chm_updated = 1U; } } @@ -1851,7 +1851,7 @@ static inline void event_enc_reject_prep(struct ll_conn *conn, pdu->len += offsetof(struct pdu_data_llctrl, reject_ind); - conn->llcp.encryption.error_code = 0; + conn->llcp.encryption.error_code = 0U; } static inline void event_enc_prep(struct ll_conn *conn) @@ -2035,7 +2035,7 @@ static inline void event_fex_prep(struct ll_conn *conn) static inline void event_vex_prep(struct ll_conn *conn) { - if (conn->llcp_version.tx == 0) { + if (conn->llcp_version.tx == 0U) { struct node_tx *tx; tx = mem_acquire(&mem_conn_tx_ctrl.free); @@ -2048,7 +2048,7 @@ static inline void event_vex_prep(struct ll_conn *conn) conn->llcp_ack = conn->llcp_req; /* set version ind tx-ed flag */ - conn->llcp_version.tx = 1; + conn->llcp_version.tx = 1U; /* place the version ind packet as next in tx queue */ pdu->ll_id = PDU_DATA_LLID_CTRL; @@ -2137,7 +2137,7 @@ static inline void event_conn_param_req(struct ll_conn *conn, p->interval_max = sys_cpu_to_le16(conn->llcp_conn_param.interval_max); p->latency = sys_cpu_to_le16(conn->llcp_conn_param.latency); p->timeout = sys_cpu_to_le16(conn->llcp_conn_param.timeout); - p->preferred_periodicity = 0; + p->preferred_periodicity = 0U; p->reference_conn_event_count = sys_cpu_to_le16(event_counter); p->offset0 = sys_cpu_to_le16(0x0000); p->offset1 = sys_cpu_to_le16(0xffff); @@ -2238,8 +2238,8 @@ static inline void event_conn_param_rsp(struct ll_conn *conn) conn->llcp_conn_param.state = LLCP_CPR_STATE_UPD; /* Initiate connection update procedure */ - conn->llcp.conn_upd.win_size = 1; - conn->llcp.conn_upd.win_offset_us = 0; + conn->llcp.conn_upd.win_size = 1U; + conn->llcp.conn_upd.win_offset_us = 0U; if (conn->llcp_conn_param.preferred_periodicity) { conn->llcp.conn_upd.interval = ((conn->llcp_conn_param.interval_min / @@ -2256,7 +2256,7 @@ static inline void event_conn_param_rsp(struct ll_conn *conn) conn->llcp.conn_upd.state = LLCP_CUI_STATE_SELECT; conn->llcp.conn_upd.is_internal = !conn->llcp_conn_param.cmd; conn->llcp_type = LLCP_CONN_UPD; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; return; } @@ -2503,8 +2503,8 @@ static inline void event_len_prep(struct ll_conn *conn) /* Procedure complete */ conn->llcp_length.ack = conn->llcp_length.req; - conn->llcp_length.pause_tx = 0; - conn->procedure_expire = 0; + conn->llcp_length.pause_tx = 0U; + conn->procedure_expire = 0U; lll = &conn->lll; @@ -2696,7 +2696,7 @@ static inline void event_phy_req_prep(struct ll_conn *conn) } else if (conn->llcp_phy.tx & BIT(2)) { conn->llcp_phy.tx = BIT(2); } else { - conn->llcp_phy.tx = 0; + conn->llcp_phy.tx = 0U; } /* select only one rx phy, prefer 2M */ @@ -2707,26 +2707,26 @@ static inline void event_phy_req_prep(struct ll_conn *conn) } else if (conn->llcp_phy.rx & BIT(2)) { conn->llcp_phy.rx = BIT(2); } else { - conn->llcp_phy.rx = 0; + conn->llcp_phy.rx = 0U; } /* Initiate PHY Update Ind */ if (conn->llcp_phy.tx != conn->lll.phy_tx) { conn->llcp.phy_upd_ind.tx = conn->llcp_phy.tx; } else { - conn->llcp.phy_upd_ind.tx = 0; + conn->llcp.phy_upd_ind.tx = 0U; } if (conn->llcp_phy.rx != conn->lll.phy_rx) { conn->llcp.phy_upd_ind.rx = conn->llcp_phy.rx; } else { - conn->llcp.phy_upd_ind.rx = 0; + conn->llcp.phy_upd_ind.rx = 0U; } /* conn->llcp.phy_upd_ind.instant = 0; */ - conn->llcp.phy_upd_ind.initiate = 1; + conn->llcp.phy_upd_ind.initiate = 1U; conn->llcp.phy_upd_ind.cmd = conn->llcp_phy.cmd; conn->llcp_type = LLCP_PHY_UPD; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; } break; @@ -2765,7 +2765,7 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn, } /* reset initiate flag */ - conn->llcp.phy_upd_ind.initiate = 0; + conn->llcp.phy_upd_ind.initiate = 0U; /* Check if both tx and rx PHY unchanged */ if (!((conn->llcp.phy_upd_ind.tx | @@ -2774,7 +2774,7 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn, conn->llcp_ack = conn->llcp_req; /* 0 instant */ - conn->llcp.phy_upd_ind.instant = 0; + conn->llcp.phy_upd_ind.instant = 0U; /* generate phy update event */ if (conn->llcp.phy_upd_ind.cmd) { @@ -2786,7 +2786,7 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn, rx->hdr.type = NODE_RX_TYPE_PHY_UPDATE; upd = (void *)rx->pdu; - upd->status = 0; + upd->status = 0U; upd->tx = lll->phy_tx; upd->rx = lll->phy_rx; @@ -2855,7 +2855,7 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn, rx->hdr.type = NODE_RX_TYPE_PHY_UPDATE; upd = (void *)rx->pdu; - upd->status = 0; + upd->status = 0U; upd->tx = lll->phy_tx; upd->rx = lll->phy_rx; } else { @@ -2911,7 +2911,7 @@ static u8_t conn_upd_recv(struct ll_conn *conn, memq_link_t *link, sys_le16_to_cpu(pdu->llctrl.conn_update_ind.timeout); conn->llcp.conn_upd.instant = instant; conn->llcp.conn_upd.state = LLCP_CUI_STATE_INPROG; - conn->llcp.conn_upd.is_internal = 0; + conn->llcp.conn_upd.is_internal = 0U; LL_ASSERT(!conn->llcp_rx); @@ -2920,7 +2920,7 @@ static u8_t conn_upd_recv(struct ll_conn *conn, memq_link_t *link, *rx = NULL; conn->llcp_type = LLCP_CONN_UPD; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) if ((conn->llcp_conn_param.req != conn->llcp_conn_param.ack) && @@ -2935,7 +2935,7 @@ static u8_t conn_upd_recv(struct ll_conn *conn, memq_link_t *link, static u8_t chan_map_upd_recv(struct ll_conn *conn, struct node_rx_pdu *rx, struct pdu_data *pdu) { - u8_t err = 0; + u8_t err = 0U; u16_t instant; instant = sys_le16_to_cpu(pdu->llctrl.chan_map_ind.instant); @@ -2956,10 +2956,10 @@ static u8_t chan_map_upd_recv(struct ll_conn *conn, struct node_rx_pdu *rx, memcpy(&conn->llcp.chan_map.chm[0], &pdu->llctrl.chan_map_ind.chm[0], sizeof(conn->llcp.chan_map.chm)); conn->llcp.chan_map.instant = instant; - conn->llcp.chan_map.initiate = 0; + conn->llcp.chan_map.initiate = 0U; conn->llcp_type = LLCP_CHAN_MAP; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; chan_map_upd_recv_exit: /* Mark for buffer for release */ @@ -3205,7 +3205,7 @@ static int feature_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx, conn->llcp_features &= feat_get(&req->features[0]); /* features exchanged */ - conn->common.fex_valid = 1; + conn->common.fex_valid = 1U; /* Enqueue feature response */ pdu_tx = (void *)tx->pdu; @@ -3240,10 +3240,10 @@ static void feature_rsp_recv(struct ll_conn *conn, struct pdu_data *pdu_rx) conn->llcp_features &= feat_get(&rsp->features[0]); /* features exchanged */ - conn->common.fex_valid = 1; + conn->common.fex_valid = 1U; /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; } #if defined(CONFIG_BT_CTLR_LE_ENC) @@ -3261,7 +3261,7 @@ static int pause_enc_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx, } /* key refresh */ - conn->refresh = 1; + conn->refresh = 1U; } else if (!conn->lll.role) { /* acquire tx mem */ tx = mem_acquire(&mem_conn_tx_ctrl.free); @@ -3279,7 +3279,7 @@ static int pause_enc_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx, } /* pause data packet rx */ - conn->pause_rx = 1; + conn->pause_rx = 1U; /* disable receive encryption */ conn->lll.enc_rx = 0; @@ -3312,7 +3312,7 @@ static int version_ind_send(struct ll_conn *conn, struct node_rx_pdu *rx, if (!tx) { return -ENOBUFS; } - conn->llcp_version.tx = 1; + conn->llcp_version.tx = 1U; pdu_tx = (void *)tx->pdu; pdu_tx->ll_id = PDU_DATA_LLID_CTRL; @@ -3332,7 +3332,7 @@ static int version_ind_send(struct ll_conn *conn, struct node_rx_pdu *rx, rx->hdr.type = NODE_RX_TYPE_DC_PDU_RELEASE; } else if (!conn->llcp_version.rx) { /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; } else { /* Tx-ed and Rx-ed before, ignore this invalid Rx. */ @@ -3347,7 +3347,7 @@ static int version_ind_send(struct ll_conn *conn, struct node_rx_pdu *rx, conn->llcp_version.company_id = sys_le16_to_cpu(v->company_id); conn->llcp_version.sub_version_number = sys_le16_to_cpu(v->sub_version_number); - conn->llcp_version.rx = 1; + conn->llcp_version.rx = 1U; return 0; } @@ -3404,8 +3404,8 @@ static inline void reject_ind_conn_upd_recv(struct ll_conn *conn, conn->llcp_conn_param.state = LLCP_CPR_STATE_UPD; - conn->llcp.conn_upd.win_size = 1; - conn->llcp.conn_upd.win_offset_us = 0; + conn->llcp.conn_upd.win_size = 1U; + conn->llcp.conn_upd.win_offset_us = 0U; conn->llcp.conn_upd.interval = conn->llcp_conn_param.interval_max; conn->llcp.conn_upd.latency = conn->llcp_conn_param.latency; @@ -3414,7 +3414,7 @@ static inline void reject_ind_conn_upd_recv(struct ll_conn *conn, conn->llcp.conn_upd.state = LLCP_CUI_STATE_USE; conn->llcp.conn_upd.is_internal = !conn->llcp_conn_param.cmd; conn->llcp_type = LLCP_CONN_UPD; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; goto reject_ind_conn_upd_recv_exit; } @@ -3434,7 +3434,7 @@ static inline void reject_ind_conn_upd_recv(struct ll_conn *conn, conn->llcp_conn_param.req; /* Stop procedure timeout */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; /* update to next ticks offsets */ if (lll->role) { @@ -3457,7 +3457,7 @@ static inline void reject_ind_conn_upd_recv(struct ll_conn *conn, cu->interval = lll->interval; cu->latency = lll->latency; cu->timeout = conn->supervision_reload * - lll->interval * 125 / 1000; + lll->interval * 125U / 1000; return; @@ -3491,7 +3491,7 @@ static inline void reject_ind_phy_upd_recv(struct ll_conn *conn, conn->lll.phy_tx_time = conn->lll.phy_tx; /* Stop procedure timeout */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; } /* skip event generation if not cmd initiated */ @@ -3544,11 +3544,11 @@ static void reject_ext_ind_recv(struct ll_conn *conn, struct node_rx_pdu *rx, switch (rej_ext_ind->reject_opcode) { case PDU_DATA_LLCTRL_TYPE_ENC_REQ: /* resume data packet rx and tx */ - conn->pause_rx = 0; - conn->pause_tx = 0; + conn->pause_rx = 0U; + conn->pause_tx = 0U; /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; /* enqueue as if it were a reject ind */ pdu_rx->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_REJECT_IND; @@ -3614,7 +3614,7 @@ static int phy_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx, conn->llcp_phy.req) { conn->llcp_phy.ack--; - conn->llcp_phy.cmd = 0; + conn->llcp_phy.cmd = 0U; conn->llcp_phy.tx = conn->phy_pref_tx; @@ -3671,7 +3671,7 @@ static inline u8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link, /* Procedure complete */ conn->llcp_phy.ack = conn->llcp_phy.req; - conn->procedure_expire = 0; + conn->procedure_expire = 0U; /* Ignore event generation if not local cmd initiated */ if (!conn->llcp_phy.cmd) { @@ -3685,7 +3685,7 @@ static inline u8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link, (*rx)->hdr.type = NODE_RX_TYPE_PHY_UPDATE; p = (void *)pdu_rx; - p->status = 0; + p->status = 0U; p->tx = conn->lll.phy_tx; p->rx = conn->lll.phy_rx; @@ -3715,13 +3715,13 @@ static inline u8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link, conn->llcp.phy_upd_ind.cmd = conn->llcp_phy.cmd; /* Procedure complete, just wait for instant */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; } conn->llcp.phy_upd_ind.tx = ind->s_to_m_phy; conn->llcp.phy_upd_ind.rx = ind->m_to_s_phy; conn->llcp.phy_upd_ind.instant = instant; - conn->llcp.phy_upd_ind.initiate = 0; + conn->llcp.phy_upd_ind.initiate = 0U; LL_ASSERT(!conn->llcp_rx); @@ -3730,7 +3730,7 @@ static inline u8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link, *rx = NULL; conn->llcp_type = LLCP_PHY_UPD; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; if (conn->llcp.phy_upd_ind.tx) { conn->lll.phy_tx_time = conn->llcp.phy_upd_ind.tx; @@ -3765,7 +3765,7 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx, &pdu_tx->llctrl.enc_req.ivm[0], 4); /* pause data packet tx */ - conn->pause_tx = 1; + conn->pause_tx = 1U; /* Start Procedure Timeout (this will not replace terminate * procedure which always gets place before any packets @@ -3776,7 +3776,7 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx, case PDU_DATA_LLCTRL_TYPE_ENC_RSP: /* pause data packet tx */ - conn->pause_tx = 1; + conn->pause_tx = 1U; break; case PDU_DATA_LLCTRL_TYPE_START_ENC_REQ: @@ -3788,10 +3788,10 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx, case PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_REQ: /* pause data packet tx */ - conn->pause_tx = 1; + conn->pause_tx = 1U; /* key refresh */ - conn->refresh = 1; + conn->refresh = 1U; /* Start Procedure Timeout (this will not replace terminate * procedure which always gets place before any packets @@ -3806,17 +3806,17 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx, enc_req_reused_send(conn, tx); } else { /* pause data packet tx */ - conn->pause_tx = 1; + conn->pause_tx = 1U; } break; case PDU_DATA_LLCTRL_TYPE_REJECT_IND: /* resume data packet rx and tx */ - conn->pause_rx = 0; - conn->pause_tx = 0; + conn->pause_rx = 0U; + conn->pause_tx = 0U; /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; break; #endif /* CONFIG_BT_CTLR_LE_ENC */ @@ -3825,7 +3825,7 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx, if ((conn->llcp_length.req != conn->llcp_length.ack) && (conn->llcp_length.state == LLCP_LENGTH_STATE_ACK_WAIT)) { /* pause data packet tx */ - conn->llcp_length.pause_tx = 1; + conn->llcp_length.pause_tx = 1U; /* wait for response */ conn->llcp_length.state = LLCP_LENGTH_STATE_RSP_WAIT; @@ -3963,7 +3963,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) } else { /* conn param req procedure, if any, is complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */ } } @@ -4019,7 +4019,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, &pdu_rx->llctrl.enc_req.ivm[0], 4); /* pause rx data packets */ - conn->pause_rx = 1; + conn->pause_rx = 1U; /* Start Procedure Timeout (TODO: this shall not replace * terminate procedure). @@ -4041,7 +4041,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, &pdu_rx->llctrl.enc_rsp.ivs[0], 4); /* pause rx data packets */ - conn->pause_rx = 1; + conn->pause_rx = 1U; /* Mark for buffer for release */ (*rx)->hdr.type = NODE_RX_TYPE_DC_PDU_RELEASE; @@ -4059,10 +4059,10 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, } /* start enc rsp to be scheduled in master prepare */ - conn->llcp.encryption.initiate = 0; + conn->llcp.encryption.initiate = 0U; if (conn->llcp_req == conn->llcp_ack) { conn->llcp_type = LLCP_ENCRYPTION; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; } /* Mark for buffer for release */ @@ -4082,10 +4082,10 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, (conn->llcp_type == LLCP_ENCRYPTION)); /* start enc rsp to be scheduled in slave prepare */ - conn->llcp.encryption.initiate = 0; + conn->llcp.encryption.initiate = 0U; if (conn->llcp_req == conn->llcp_ack) { conn->llcp_type = LLCP_ENCRYPTION; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; } #else /* CONFIG_BT_CTLR_FAST_ENC */ nack = start_enc_rsp_send(conn, NULL); @@ -4094,26 +4094,26 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, } /* resume data packet rx and tx */ - conn->pause_rx = 0; - conn->pause_tx = 0; + conn->pause_rx = 0U; + conn->pause_tx = 0U; #endif /* CONFIG_BT_CTLR_FAST_ENC */ } else { /* resume data packet rx and tx */ - conn->pause_rx = 0; - conn->pause_tx = 0; + conn->pause_rx = 0U; + conn->pause_tx = 0U; } /* enqueue the start enc resp (encryption change/refresh) */ if (conn->refresh) { - conn->refresh = 0; + conn->refresh = 0U; /* key refresh event */ (*rx)->hdr.type = NODE_RX_TYPE_ENC_REFRESH; } /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; break; #endif /* CONFIG_BT_CTLR_LE_ENC */ @@ -4186,11 +4186,11 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, } /* resume data packet rx and tx */ - conn->pause_rx = 0; - conn->pause_tx = 0; + conn->pause_rx = 0U; + conn->pause_tx = 0U; /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; break; #endif /* CONFIG_BT_CTLR_LE_ENC */ @@ -4276,7 +4276,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, (latency > 499) || (timeout < 10) || (timeout > 3200) || - ((timeout * 4) <= + ((timeout * 4U) <= ((latency + 1) * interval_max)) || (preferred_periodicity > interval_max)) { nack = reject_ext_ind_send(conn, *rx, @@ -4318,7 +4318,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, (conn->llcp_conn_param.latency != lll->latency) || (RADIO_CONN_EVENTS(conn->llcp_conn_param.timeout * - 10000, + 10000U, lll->interval * 1250) != conn->supervision_reload)) { @@ -4339,8 +4339,8 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, LLCP_CPR_STATE_APP_WAIT; } } else { - conn->llcp_conn_param.status = 0; - conn->llcp_conn_param.cmd = 0; + conn->llcp_conn_param.status = 0U; + conn->llcp_conn_param.cmd = 0U; conn->llcp_conn_param.state = LLCP_CPR_STATE_RSP; @@ -4380,7 +4380,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, (interval_min > interval_max) || (latency > 499) || (timeout < 10) || (timeout > 3200) || - ((timeout * 4) <= + ((timeout * 4U) <= ((latency + 1) * interval_max)) || (preferred_periodicity > interval_max)) { nack = reject_ext_ind_send(conn, *rx, @@ -4420,15 +4420,15 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, lll->interval) || (conn->llcp_conn_param.latency != lll->latency) || (RADIO_CONN_EVENTS(conn->llcp_conn_param.timeout * - 10000, + 10000U, lll->interval * 1250) != conn->supervision_reload)) { conn->llcp_conn_param.state = LLCP_CPR_STATE_APP_WAIT; } else { - conn->llcp_conn_param.status = 0; - conn->llcp_conn_param.cmd = 0; + conn->llcp_conn_param.status = 0U; + conn->llcp_conn_param.cmd = 0U; conn->llcp_conn_param.state = LLCP_CPR_STATE_RSP; @@ -4476,7 +4476,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, (interval_min > interval_max) || (latency > 499) || (timeout < 10) || (timeout > 3200) || - ((timeout * 4) <= + ((timeout * 4U) <= ((latency + 1) * interval_max)) || (preferred_periodicity > interval_max)) { nack = reject_ext_ind_send(conn, *rx, @@ -4486,7 +4486,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, } /* Stop procedure timeout */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; /* save parameters to be used to select offset */ @@ -4545,7 +4545,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, } /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; /* Mark for buffer for release */ (*rx)->hdr.type = NODE_RX_TYPE_DC_PDU_RELEASE; @@ -4567,7 +4567,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, struct node_rx_cu *cu; /* Mark CPR as unsupported */ - conn->llcp_conn_param.disabled = 1; + conn->llcp_conn_param.disabled = 1U; /* TODO: check for unsupported remote feature reason */ if (!conn->lll.role) { @@ -4576,8 +4576,8 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, conn->llcp_conn_param.state = LLCP_CPR_STATE_UPD; - conn->llcp.conn_upd.win_size = 1; - conn->llcp.conn_upd.win_offset_us = 0; + conn->llcp.conn_upd.win_size = 1U; + conn->llcp.conn_upd.win_offset_us = 0U; conn->llcp.conn_upd.interval = conn->llcp_conn_param.interval_max; conn->llcp.conn_upd.latency = @@ -4589,7 +4589,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, conn->llcp.conn_upd.is_internal = !conn->llcp_conn_param.cmd; conn->llcp_type = LLCP_CONN_UPD; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; /* Mark for buffer for release */ (*rx)->hdr.type = NODE_RX_TYPE_DC_PDU_RELEASE; @@ -4622,14 +4622,14 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, cu->interval = lll->interval; cu->latency = lll->latency; cu->timeout = conn->supervision_reload * - lll->interval * 125 / 1000; + lll->interval * 125U / 1000; #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */ #if defined(CONFIG_BT_CTLR_DATA_LENGTH) } else if (conn->llcp_length.req != conn->llcp_length.ack) { /* Procedure complete */ conn->llcp_length.ack = conn->llcp_length.req; - conn->llcp_length.pause_tx = 0; + conn->llcp_length.pause_tx = 0U; /* propagate the data length procedure to * host @@ -4655,7 +4655,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, (*rx)->hdr.type = NODE_RX_TYPE_PHY_UPDATE; p = (void *)pdu_rx; - p->status = 0; + p->status = 0U; p->tx = lll->phy_tx; p->rx = lll->phy_rx; } else { @@ -4690,7 +4690,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, } /* Procedure complete */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; break; #if defined(CONFIG_BT_CTLR_DATA_LENGTH) @@ -4765,7 +4765,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, conn->llcp_phy.req) { conn->llcp_phy.ack--; - conn->llcp_phy.cmd = 0; + conn->llcp_phy.cmd = 0U; conn->llcp_phy.tx = conn->phy_pref_tx; @@ -4802,7 +4802,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, conn->llcp_phy.rx &= p->tx_phys; /* Procedure timeout is stopped */ - conn->procedure_expire = 0; + conn->procedure_expire = 0U; } /* Mark for buffer for release */ @@ -4857,10 +4857,10 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, memcpy(&conn->llcp.chan_map.chm[0], data_chan_map, sizeof(conn->llcp.chan_map.chm)); /* conn->llcp.chan_map.instant = 0; */ - conn->llcp.chan_map.initiate = 1; + conn->llcp.chan_map.initiate = 1U; conn->llcp_type = LLCP_CHAN_MAP; - conn->llcp_ack -= 2; + conn->llcp_ack -= 2U; } /* Mark for buffer for release */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_master.c b/subsys/bluetooth/controller/ll_sw/ull_master.c index c4cced3ac69..7cfbf7c64e9 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_master.c +++ b/subsys/bluetooth/controller/ll_sw/ull_master.c @@ -153,21 +153,21 @@ u8_t ll_create_connection(u16_t scan_interval, u16_t scan_window, conn_lll->role = 0; /* FIXME: END: Move to ULL? */ - conn->connect_expire = 6; - conn->supervision_expire = 0; - conn_interval_us = (u32_t)interval * 1250; - conn->supervision_reload = RADIO_CONN_EVENTS(timeout * 10000, + conn->connect_expire = 6U; + conn->supervision_expire = 0U; + conn_interval_us = (u32_t)interval * 1250U; + conn->supervision_reload = RADIO_CONN_EVENTS(timeout * 10000U, conn_interval_us); - conn->procedure_expire = 0; + conn->procedure_expire = 0U; conn->procedure_reload = RADIO_CONN_EVENTS(40000000, conn_interval_us); #if defined(CONFIG_BT_CTLR_LE_PING) - conn->apto_expire = 0; + conn->apto_expire = 0U; /* APTO in no. of connection events */ conn->apto_reload = RADIO_CONN_EVENTS((30000000), conn_interval_us); - conn->appto_expire = 0; + conn->appto_expire = 0U; /* Dispatch LE Ping PDU 6 connection events (that peer would listen to) * before 30s timeout * TODO: "peer listens to" is greater than 30s due to latency @@ -177,33 +177,33 @@ u8_t ll_create_connection(u16_t scan_interval, u16_t scan_window, conn->apto_reload; #endif /* CONFIG_BT_CTLR_LE_PING */ - conn->common.fex_valid = 0; + conn->common.fex_valid = 0U; - conn->llcp_req = conn->llcp_ack = conn->llcp_type = 0; + conn->llcp_req = conn->llcp_ack = conn->llcp_type = 0U; conn->llcp_rx = NULL; conn->llcp_features = LL_FEAT; - conn->llcp_version.tx = conn->llcp_version.rx = 0; - conn->llcp_terminate.reason_peer = 0; + conn->llcp_version.tx = conn->llcp_version.rx = 0U; + conn->llcp_terminate.reason_peer = 0U; /* NOTE: use allocated link for generating dedicated * terminate ind rx node */ conn->llcp_terminate.node_rx.hdr.link = link; #if defined(CONFIG_BT_CTLR_LE_ENC) - conn->pause_tx = conn->pause_rx = conn->refresh = 0; + conn->pause_tx = conn->pause_rx = conn->refresh = 0U; #endif /* CONFIG_BT_CTLR_LE_ENC */ #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) - conn->llcp_conn_param.req = 0; - conn->llcp_conn_param.ack = 0; - conn->llcp_conn_param.disabled = 0; + conn->llcp_conn_param.req = 0U; + conn->llcp_conn_param.ack = 0U; + conn->llcp_conn_param.disabled = 0U; #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */ #if defined(CONFIG_BT_CTLR_PHY) - conn->llcp_phy.req = conn->llcp_phy.ack = 0; + conn->llcp_phy.req = conn->llcp_phy.ack = 0U; conn->phy_pref_tx = ull_conn_default_phy_tx_get(); conn->phy_pref_rx = ull_conn_default_phy_rx_get(); - conn->phy_pref_flags = 0; + conn->phy_pref_flags = 0U; #endif /* CONFIG_BT_CTLR_PHY */ conn->tx_head = conn->tx_ctrl = conn->tx_ctrl_last = @@ -300,7 +300,7 @@ u8_t ll_chm_update(u8_t *chm) memcpy(conn->llcp.chan_map.chm, chm, sizeof(conn->llcp.chan_map.chm)); /* conn->llcp.chan_map.instant = 0; */ - conn->llcp.chan_map.initiate = 1; + conn->llcp.chan_map.initiate = 1U; conn->llcp_type = LLCP_CHAN_MAP; conn->llcp_req++; @@ -375,7 +375,7 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk) return BT_HCI_ERR_CMD_DISALLOWED; } - conn->llcp.encryption.initiate = 1; + conn->llcp.encryption.initiate = 1U; conn->llcp_type = LLCP_ENCRYPTION; conn->llcp_req++; @@ -411,8 +411,8 @@ void ull_master_setup(memq_link_t *link, struct node_rx_hdr *rx, chan_sel = pdu->chan_sel; cc = (void *)pdu; - cc->status = 0; - cc->role = 0; + cc->status = 0U; + cc->role = 0U; cc->peer_addr_type = scan->lll.adv_addr_type; memcpy(cc->peer_addr, scan->lll.adv_addr, BDADDR_SIZE); cc->interval = lll->interval; @@ -464,7 +464,7 @@ void ull_master_setup(memq_link_t *link, struct node_rx_hdr *rx, ll_rx_sched(); /* TODO: active_to_start feature port */ - conn->evt.ticks_active_to_start = 0; + conn->evt.ticks_active_to_start = 0U; conn->evt.ticks_xtal_to_start = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US); conn->evt.ticks_preempt_to_start = @@ -480,7 +480,7 @@ void ull_master_setup(memq_link_t *link, struct node_rx_hdr *rx, if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) { ticks_slot_overhead = ticks_slot_offset; } else { - ticks_slot_overhead = 0; + ticks_slot_overhead = 0U; } conn_interval_us = lll->interval * 1250; @@ -761,7 +761,7 @@ static void access_addr_get(u8_t access_addr[]) u8_t bit_idx; u8_t retry; - retry = 3; + retry = 3U; again: LL_ASSERT(retry); retry--; @@ -769,12 +769,12 @@ again: bt_rand(access_addr, 4); aa = sys_get_le32(access_addr); - bit_idx = 31; - transitions = 0; - consecutive_cnt = 1; + bit_idx = 31U; + transitions = 0U; + consecutive_cnt = 1U; #if defined(CONFIG_BT_CTLR_PHY_CODED) - ones_count_lsb8 = 0; - transitions_lsb16 = 0; + ones_count_lsb8 = 0U; + transitions_lsb16 = 0U; #endif /* CONFIG_BT_CTLR_PHY_CODED */ consecutive_bit = (aa >> bit_idx) & 0x01; while (bit_idx--) { @@ -789,7 +789,7 @@ again: if (bit == consecutive_bit) { consecutive_cnt++; } else { - consecutive_cnt = 1; + consecutive_cnt = 1U; consecutive_bit = bit; transitions++; @@ -823,7 +823,7 @@ again: (((bit_idx < 29) && (transitions < 1)) || ((bit_idx < 28) && (transitions < 2))))) { if (consecutive_bit) { - consecutive_bit = 0; + consecutive_bit = 0U; aa &= ~BIT(bit_idx); #if defined(CONFIG_BT_CTLR_PHY_CODED) if (bit_idx < 8) { @@ -831,7 +831,7 @@ again: } #endif /* CONFIG_BT_CTLR_PHY_CODED */ } else { - consecutive_bit = 1; + consecutive_bit = 1U; aa |= BIT(bit_idx); #if defined(CONFIG_BT_CTLR_PHY_CODED) if (bit_idx < 8) { @@ -844,7 +844,7 @@ again: consecutive_cnt = consecutive_cnt_prev; transitions = transitions_prev; } else { - consecutive_cnt = 1; + consecutive_cnt = 1U; transitions++; } diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan.c b/subsys/bluetooth/controller/ll_sw/ull_scan.c index 2bd494a91f5..0d5c2767ea3 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_scan.c +++ b/subsys/bluetooth/controller/ll_sw/ull_scan.c @@ -95,7 +95,7 @@ int ull_scan_reset(void) u16_t handle; int err; - for (handle = 0; handle < BT_CTLR_SCAN_MAX; handle++) { + for (handle = 0U; handle < BT_CTLR_SCAN_MAX; handle++) { (void)disable(handle); } @@ -133,7 +133,7 @@ u8_t ull_scan_params_set(struct ll_scan_set *scan, u8_t type, lll->filter_policy = filter_policy; lll->interval = interval; - lll->ticks_window = HAL_TICKER_US_TO_TICKS((u64_t)window * 625); + lll->ticks_window = HAL_TICKER_US_TO_TICKS((u64_t)window * 625U); scan->own_addr_type = own_addr_type; @@ -169,10 +169,10 @@ u8_t ull_scan_enable(struct ll_scan_set *scan) ull_hdr_init(&scan->ull); lll_hdr_init(lll, scan); - ticks_interval = HAL_TICKER_US_TO_TICKS((u64_t)lll->interval * 625); + ticks_interval = HAL_TICKER_US_TO_TICKS((u64_t)lll->interval * 625U); /* TODO: active_to_start feature port */ - scan->evt.ticks_active_to_start = 0; + scan->evt.ticks_active_to_start = 0U; scan->evt.ticks_xtal_to_start = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US); scan->evt.ticks_preempt_to_start = @@ -197,15 +197,15 @@ u8_t ull_scan_enable(struct ll_scan_set *scan) if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) { ticks_slot_overhead = ticks_slot_offset; } else { - ticks_slot_overhead = 0; + ticks_slot_overhead = 0U; } ticks_anchor = ticker_ticks_now_get(); #if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_CTLR_SCHED_ADVANCED) if (!lll->conn) { - u32_t ticks_ref = 0; - u32_t offset_us = 0; + u32_t ticks_ref = 0U; + u32_t offset_us = 0U; ull_sched_after_mstr_slot_get(TICKER_USER_ID_THREAD, (ticks_slot_offset + @@ -226,7 +226,7 @@ u8_t ull_scan_enable(struct ll_scan_set *scan) ret = ticker_start(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD, TICKER_ID_SCAN_BASE, ticks_anchor, 0, ticks_interval, - HAL_TICKER_REMAINDER((u64_t)lll->interval * 625), + HAL_TICKER_REMAINDER((u64_t)lll->interval * 625U), TICKER_NULL_LAZY, (scan->evt.ticks_slot + ticks_slot_overhead), ticker_cb, scan, @@ -237,7 +237,7 @@ u8_t ull_scan_enable(struct ll_scan_set *scan) return BT_HCI_ERR_CMD_DISALLOWED; } - scan->is_enabled = 1; + scan->is_enabled = 1U; #if defined(CONFIG_BT_CTLR_PRIVACY) #if defined(CONFIG_BT_BROADCASTER) @@ -428,7 +428,7 @@ static u8_t disable(u16_t handle) return ret; } - scan->is_enabled = 0; + scan->is_enabled = 0U; #if defined(CONFIG_BT_CTLR_PRIVACY) #if defined(CONFIG_BT_BROADCASTER) diff --git a/subsys/bluetooth/controller/ll_sw/ull_slave.c b/subsys/bluetooth/controller/ll_sw/ull_slave.c index 19bdcb429a0..6815ed49790 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_slave.c +++ b/subsys/bluetooth/controller/ll_sw/ull_slave.c @@ -83,21 +83,21 @@ void ull_slave_setup(memq_link_t *link, struct node_rx_hdr *rx, lll->latency = sys_le16_to_cpu(pdu_adv->connect_ind.latency); win_offset = sys_le16_to_cpu(pdu_adv->connect_ind.win_offset); - conn_interval_us = interval * 1250; + conn_interval_us = interval * 1250U; /* calculate the window widening */ lll->slave.sca = pdu_adv->connect_ind.sca; lll->slave.window_widening_periodic_us = (((lll_conn_ppm_local_get() + lll_conn_ppm_get(lll->slave.sca)) * - conn_interval_us) + (1000000 - 1)) / 1000000; + conn_interval_us) + (1000000 - 1)) / 1000000U; lll->slave.window_widening_max_us = (conn_interval_us >> 1) - TIFS_US; - lll->slave.window_size_event_us = pdu_adv->connect_ind.win_size * 1250; + lll->slave.window_size_event_us = pdu_adv->connect_ind.win_size * 1250U; /* procedure timeouts */ timeout = sys_le16_to_cpu(pdu_adv->connect_ind.timeout); conn->supervision_reload = - RADIO_CONN_EVENTS((timeout * 10 * 1000), conn_interval_us); + RADIO_CONN_EVENTS((timeout * 10U * 1000U), conn_interval_us); conn->procedure_reload = RADIO_CONN_EVENTS((40 * 1000 * 1000), conn_interval_us); @@ -125,8 +125,8 @@ void ull_slave_setup(memq_link_t *link, struct node_rx_hdr *rx, memcpy(peer_addr, pdu_adv->connect_ind.init_addr, BDADDR_SIZE); cc = (void *)pdu_adv; - cc->status = 0; - cc->role = 1; + cc->status = 0U; + cc->role = 1U; cc->peer_addr_type = peer_addr_type; memcpy(cc->peer_addr, peer_addr, BDADDR_SIZE); cc->interval = lll->interval; @@ -263,7 +263,7 @@ void ull_slave_setup(memq_link_t *link, struct node_rx_hdr *rx, #endif /* TODO: active_to_start feature port */ - conn->evt.ticks_active_to_start = 0; + conn->evt.ticks_active_to_start = 0U; conn->evt.ticks_xtal_to_start = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US); conn->evt.ticks_preempt_to_start = @@ -279,13 +279,13 @@ void ull_slave_setup(memq_link_t *link, struct node_rx_hdr *rx, if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) { ticks_slot_overhead = ticks_slot_offset; } else { - ticks_slot_overhead = 0; + ticks_slot_overhead = 0U; } conn_interval_us -= lll->slave.window_widening_periodic_us; conn_offset_us = ftr->us_radio_end; - conn_offset_us += ((u64_t)win_offset + 1) * 1250; + conn_offset_us += ((u64_t)win_offset + 1) * 1250U; conn_offset_us -= EVENT_OVERHEAD_START_US; conn_offset_us -= EVENT_JITTER_US << 1; conn_offset_us -= EVENT_JITTER_US; @@ -438,14 +438,14 @@ u8_t ll_start_enc_req_send(u16_t handle, u8_t error_code, } if (error_code) { - if (conn->refresh == 0) { + if (conn->refresh == 0U) { ret = ull_conn_allowed_check(conn); if (ret) { return ret; } conn->llcp.encryption.error_code = error_code; - conn->llcp.encryption.initiate = 0; + conn->llcp.encryption.initiate = 0U; conn->llcp_type = LLCP_ENCRYPTION; conn->llcp_req++; @@ -468,8 +468,8 @@ u8_t ll_start_enc_req_send(u16_t handle, u8_t error_code, return ret; } - conn->llcp.encryption.error_code = 0; - conn->llcp.encryption.initiate = 0; + conn->llcp.encryption.error_code = 0U; + conn->llcp.encryption.initiate = 0U; conn->llcp_type = LLCP_ENCRYPTION; conn->llcp_req++; diff --git a/subsys/bluetooth/controller/ticker/ticker.c b/subsys/bluetooth/controller/ticker/ticker.c index 19d3a1b4b24..3fa92531205 100644 --- a/subsys/bluetooth/controller/ticker/ticker.c +++ b/subsys/bluetooth/controller/ticker/ticker.c @@ -180,7 +180,7 @@ static void ticker_by_next_slot_get(struct ticker_instance *instance, } while ((_ticker_id_head != TICKER_NULL) && - ((ticker = &node[_ticker_id_head])->ticks_slot == 0)) { + ((ticker = &node[_ticker_id_head])->ticks_slot == 0U)) { _ticks_to_expire += ticker->ticks_to_expire; _ticker_id_head = ticker->next; } @@ -220,7 +220,7 @@ static u8_t ticker_enqueue(struct ticker_instance *instance, u8_t id) (ticker_current = &node[current])->ticks_to_expire))) { ticks_to_expire -= ticks_to_expire_current; - if (ticker_current->ticks_slot != 0) { + if (ticker_current->ticks_slot != 0U) { ticks_slot_previous = ticker_current->ticks_slot; ticker_id_slot_previous = current; } else { @@ -237,7 +237,7 @@ static u8_t ticker_enqueue(struct ticker_instance *instance, u8_t id) collide = ticker_by_slot_get(&node[0], current, ticks_to_expire + ticker_new->ticks_slot); - if ((ticker_new->ticks_slot == 0) || + if ((ticker_new->ticks_slot == 0U) || ((ticks_slot_previous <= ticks_to_expire) && (collide == TICKER_NULL))) { ticker_new->ticks_to_expire = ticks_to_expire; @@ -373,7 +373,7 @@ void ticker_worker(void *param) ticker_id_head = ticker->next; /* skip if not scheduled to execute */ - if (((ticker->req - ticker->ack) & 0xff) != 1) { + if (((ticker->req - ticker->ack) & 0xff) != 1U) { continue; } @@ -519,8 +519,8 @@ static inline void ticker_job_node_update(struct ticker_node *ticker, ticks_to_expire = 0U; } - if ((ticker->ticks_periodic != 0) && - (user_op->params.update.lazy != 0)) { + if ((ticker->ticks_periodic != 0U) && + (user_op->params.update.lazy != 0U)) { user_op->params.update.lazy--; while ((ticks_to_expire > ticker->ticks_periodic) && @@ -553,7 +553,7 @@ static inline void ticker_job_node_update(struct ticker_node *ticker, ticker->ticks_slot = 0U; } - if (user_op->params.update.force != 0) { + if (user_op->params.update.force != 0U) { ticker->force = user_op->params.update.force; } @@ -645,21 +645,21 @@ static inline u8_t ticker_job_list_manage(struct ticker_instance *instance, * set status and continue. */ if ((user_op->op > TICKER_USER_OP_TYPE_STOP) || - (state == 0) || + (state == 0U) || ((user_op->op == TICKER_USER_OP_TYPE_UPDATE) && - (user_op->params.update.ticks_drift_plus == 0) && - (user_op->params.update.ticks_drift_minus == 0) && - (user_op->params.update.ticks_slot_plus == 0) && - (user_op->params.update.ticks_slot_minus == 0) && - (user_op->params.update.lazy == 0) && - (user_op->params.update.force == 0))) { + (user_op->params.update.ticks_drift_plus == 0U) && + (user_op->params.update.ticks_drift_minus == 0U) && + (user_op->params.update.ticks_slot_plus == 0U) && + (user_op->params.update.ticks_slot_minus == 0U) && + (user_op->params.update.lazy == 0U) && + (user_op->params.update.force == 0U))) { ticker_job_op_cb(user_op, TICKER_STATUS_FAILURE); continue; } /* Delete node, if not expired */ - if (state == 1) { + if (state == 1U) { ticker_job_node_manage(instance, ticker, user_op, ticks_elapsed, insert_head); @@ -727,7 +727,7 @@ static inline void ticker_job_worker_bh(struct ticker_instance *instance, } /* save current ticks_slot_previous */ - if (ticker->ticks_slot != 0) { + if (ticker->ticks_slot != 0U) { instance->ticker_id_slot_previous = id_expired; instance->ticks_slot_previous = ticker->ticks_slot; } @@ -739,7 +739,7 @@ static inline void ticker_job_worker_bh(struct ticker_instance *instance, instance->ticker_id_head = ticker->next; /* ticker will be restarted if periodic */ - if (ticker->ticks_periodic != 0) { + if (ticker->ticks_periodic != 0U) { u32_t count; /* Prepare for next interval */ @@ -848,7 +848,7 @@ static inline u32_t ticker_job_insert(struct ticker_instance *instance, } /* occupied, try next interval */ - if (ticker->ticks_periodic != 0) { + if (ticker->ticks_periodic != 0U) { ticker->ticks_to_expire += ticker->ticks_periodic + ticker_remainder_inc(ticker); ticker->lazy_current++; @@ -924,7 +924,7 @@ static inline void ticker_job_list_insert(struct ticker_instance *instance, continue; } - if (((ticker->req - ticker->ack) & 0xff) != 0) { + if (((ticker->req - ticker->ack) & 0xff) != 0U) { ticker_job_op_cb(user_op, TICKER_STATUS_FAILURE); continue; diff --git a/subsys/bluetooth/controller/util/mayfly.c b/subsys/bluetooth/controller/util/mayfly.c index 792fa00b573..c7bc8889f2e 100644 --- a/subsys/bluetooth/controller/util/mayfly.c +++ b/subsys/bluetooth/controller/util/mayfly.c @@ -79,9 +79,9 @@ u32_t mayfly_enqueue(u8_t caller_id, u8_t callee_id, u8_t chain, /* already in queue */ state = (m->_req - ack) & 0x03; - if (state != 0) { + if (state != 0U) { if (chain) { - if (state != 1) { + if (state != 1U) { /* mark as ready in queue */ m->_req = ack + 1; @@ -110,7 +110,7 @@ u32_t mayfly_enqueue(u8_t caller_id, u8_t callee_id, u8_t chain, mayfly_enqueue_pend: /* set mayfly callee pending */ - mfp[callee_id] = 1; + mfp[callee_id] = 1U; /* pend the callee for execution */ mayfly_pend(caller_id, callee_id); @@ -124,7 +124,7 @@ static void dequeue(u8_t callee_id, u8_t caller_id, memq_link_t *link, u8_t req; req = m->_req; - if (((req - m->_ack) & 0x03) != 1) { + if (((req - m->_ack) & 0x03) != 1U) { u8_t ack; #if defined(MAYFLY_UT) @@ -135,7 +135,7 @@ static void dequeue(u8_t callee_id, u8_t caller_id, memq_link_t *link, static u8_t single; if (!single) { - single = 1; + single = 1U; mayfly_ut_run_test(); } } @@ -154,7 +154,7 @@ static void dequeue(u8_t callee_id, u8_t caller_id, memq_link_t *link, m->_ack = req; /* re-insert, if re-pended by interrupt */ - if (((m->_req - ack) & 0x03) == 1) { + if (((m->_req - ack) & 0x03) == 1U) { #if defined(MAYFLY_UT) printk("%s: RACE\n", __func__); #endif /* MAYFLY_UT */ @@ -174,7 +174,7 @@ void mayfly_run(u8_t callee_id) if (!mfp[callee_id]) { return; } - mfp[callee_id] = 1; + mfp[callee_id] = 1U; /* iterate through each caller queue to this callee_id */ caller_id = MAYFLY_CALLER_COUNT; @@ -190,14 +190,14 @@ void mayfly_run(u8_t callee_id) u8_t state; #if defined(MAYFLY_UT) - _state = 0; + _state = 0U; #endif /* MAYFLY_UT */ /* execute work if ready */ state = (m->_req - m->_ack) & 0x03; - if (state == 1) { + if (state == 1U) { #if defined(MAYFLY_UT) - _state = 1; + _state = 1U; #endif /* MAYFLY_UT */ /* mark mayfly as ran */ @@ -218,7 +218,7 @@ void mayfly_run(u8_t callee_id) /* yield out of mayfly_run if a mayfly function was * called. */ - if (state == 1) { + if (state == 1U) { /* pend callee (tailchain) if mayfly queue is * not empty or all caller queues are not * processed. diff --git a/subsys/bluetooth/controller/util/mfifo.h b/subsys/bluetooth/controller/util/mfifo.h index fcaef658301..ff627dce4a6 100644 --- a/subsys/bluetooth/controller/util/mfifo.h +++ b/subsys/bluetooth/controller/util/mfifo.h @@ -85,7 +85,7 @@ static inline bool mfifo_enqueue_idx_get(u8_t count, u8_t first, u8_t last, /* Non-destructive: Advance write-index modulo 'count' */ last = last + 1; if (last == count) { - last = 0; + last = 0U; } /* Is queue full? @@ -284,7 +284,7 @@ static inline void *mfifo_dequeue_iter_get(u8_t *fifo, u8_t size, u8_t count, i = *idx + 1; if (i == count) { - i = 0; + i = 0U; } p = (void *)(fifo + (*idx) * size); @@ -326,9 +326,9 @@ static inline void *mfifo_dequeue(u8_t *fifo, u8_t size, u8_t count, mem = *((void **)(fifo + _first * size)); /* Circular buffer increment read-index modulo 'count' */ - _first += 1; + _first += 1U; if (_first == count) { - _first = 0; + _first = 0U; } *first = _first; /* Write back read-index */ diff --git a/subsys/bluetooth/host/at.c b/subsys/bluetooth/host/at.c index 9f6383fb708..8bfd41b5a1b 100644 --- a/subsys/bluetooth/host/at.c +++ b/subsys/bluetooth/host/at.c @@ -52,10 +52,10 @@ int at_get_number(struct at_client *at, u32_t *val) for (i = 0U, *val = 0U; isdigit((unsigned char)at->buf[at->pos]); at->pos++, i++) { - *val = *val * 10 + at->buf[at->pos] - '0'; + *val = *val * 10U + at->buf[at->pos] - '0'; } - if (i == 0) { + if (i == 0U) { return -ENODATA; } diff --git a/subsys/bluetooth/host/avdtp.c b/subsys/bluetooth/host/avdtp.c index 3f8556eafae..0d354ad92f3 100644 --- a/subsys/bluetooth/host/avdtp.c +++ b/subsys/bluetooth/host/avdtp.c @@ -272,7 +272,7 @@ int bt_avdtp_register_sep(u8_t media_type, u8_t role, } lsep->sep.id = bt_avdtp_seid++; - lsep->sep.inuse = 0; + lsep->sep.inuse = 0U; lsep->sep.media_type = media_type; lsep->sep.tsep = role; diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 692e508ee4f..1c2fab8bb19 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -1388,7 +1388,7 @@ int bt_conn_prepare_events(struct k_poll_event events[]) BT_DBG(""); - conn_change.signaled = 0; + conn_change.signaled = 0U; k_poll_event_init(&events[ev_count++], K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &conn_change); diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 4a81df33153..431435cf5da 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -231,15 +231,15 @@ static ssize_t cf_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, static bool cf_set_value(struct gatt_cf_cfg *cfg, const u8_t *value, u16_t len) { u16_t i; - u8_t last_byte = 1; - u8_t last_bit = 1; + u8_t last_byte = 1U; + u8_t last_bit = 1U; /* Validate the bits */ - for (i = 0; i < len && i < last_byte; i++) { + for (i = 0U; i < len && i < last_byte; i++) { u8_t chg_bits = value[i] ^ cfg->data[i]; u8_t bit; - for (bit = 0; bit < last_bit; bit++) { + for (bit = 0U; bit < last_bit; bit++) { /* A client shall never clear a bit it has set */ if ((BIT(bit) & chg_bits) && (BIT(bit) & cfg->data[i])) { @@ -249,7 +249,7 @@ static bool cf_set_value(struct gatt_cf_cfg *cfg, const u8_t *value, u16_t len) } /* Set the bits for each octect */ - for (i = 0; i < len && i < last_byte; i++) { + for (i = 0U; i < len && i < last_byte; i++) { cfg->data[i] |= value[i] & ((1 << last_bit) - 1); BT_DBG("byte %u: data 0x%02x value 0x%02x", i, cfg->data[i], value[i]); @@ -906,10 +906,10 @@ ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, if (chrc->uuid->type == BT_UUID_TYPE_16) { pdu.uuid16 = sys_cpu_to_le16(BT_UUID_16(chrc->uuid)->val); - value_len += 2; + value_len += 2U; } else { memcpy(pdu.uuid, BT_UUID_128(chrc->uuid)->val, 16); - value_len += 16; + value_len += 16U; } return bt_gatt_attr_read(conn, attr, buf, len, offset, &pdu, value_len); @@ -1086,7 +1086,7 @@ ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, /* Disabled CCC is the same as no configured CCC, so clear the entry */ if (!value) { bt_addr_le_copy(&cfg->peer, BT_ADDR_LE_ANY); - cfg->value = 0; + cfg->value = 0U; } return len; @@ -1229,7 +1229,7 @@ static int gatt_indicate(struct bt_conn *conn, return -EINVAL; } - value_handle += 1; + value_handle += 1U; } buf = bt_att_create_pdu(conn, BT_ATT_OP_INDICATE, @@ -1513,7 +1513,7 @@ static u8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data) /* Clear value if not paired */ if (!bt_addr_le_is_bonded(conn->id, &conn->le.dst)) { bt_addr_le_copy(&cfg->peer, BT_ADDR_LE_ANY); - cfg->value = 0; + cfg->value = 0U; } else { /* Update address in case it has changed */ bt_addr_le_copy(&cfg->peer, &conn->le.dst); @@ -1523,7 +1523,7 @@ static u8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data) /* If all values are now disabled, reset value while disconnected */ if (!value_used) { - ccc->value = 0; + ccc->value = 0U; if (ccc->cfg_changed) { ccc->cfg_changed(attr, ccc->value); } @@ -1590,7 +1590,7 @@ static void remove_subscriptions(struct bt_conn *conn) if (!bt_addr_le_is_bonded(conn->id, &conn->le.dst) || (params->flags & BT_GATT_SUBSCRIBE_FLAG_VOLATILE)) { /* Remove subscription */ - params->value = 0; + params->value = 0U; gatt_subscription_remove(conn, prev, params); } else { update_subscription(conn, params); @@ -1778,7 +1778,7 @@ static void read_included_uuid_cb(struct bt_conn *conn, u8_t err, struct bt_uuid_128 u128; } u; - if (length != 16) { + if (length != 16U) { BT_ERR("Invalid data len %u", length); params->func(conn, NULL, params); return; @@ -1915,7 +1915,7 @@ static u16_t parse_include(struct bt_conn *conn, const void *pdu, } /* Whole PDU read without error */ - if (length == 0 && handle) { + if (length == 0U && handle) { return handle; } @@ -1995,7 +1995,7 @@ static u16_t parse_characteristic(struct bt_conn *conn, const void *pdu, } /* Whole PDU read without error */ - if (length == 0 && handle) { + if (length == 0U && handle) { return handle; } @@ -2131,7 +2131,7 @@ static u16_t parse_service(struct bt_conn *conn, const void *pdu, } /* Whole PDU read without error */ - if (length == 0 && end_handle) { + if (length == 0U && end_handle) { return end_handle; } @@ -3124,7 +3124,7 @@ static void ccc_clear(struct _bt_gatt_ccc *ccc, bt_addr_le_t *addr) } bt_addr_le_copy(&cfg->peer, BT_ADDR_LE_ANY); - cfg->value = 0; + cfg->value = 0U; } struct ccc_load { diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 9afb6542d0b..6f92bc3bdd4 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -789,7 +789,7 @@ static int hci_le_set_phy(struct bt_conn *conn) cp = net_buf_add(buf, sizeof(*cp)); cp->handle = sys_cpu_to_le16(conn->handle); - cp->all_phys = 0; + cp->all_phys = 0U; cp->tx_phys = BT_HCI_LE_PHY_PREFER_2M; cp->rx_phys = BT_HCI_LE_PHY_PREFER_2M; cp->phy_opts = BT_HCI_LE_PHY_CODED_ANY; @@ -1976,7 +1976,7 @@ static void io_capa_req(struct net_buf *buf) bt_addr_copy(&cp->bdaddr, &evt->bdaddr); cp->capability = bt_conn_get_io_capa(); cp->authentication = auth; - cp->oob_data = 0; + cp->oob_data = 0U; bt_hci_cmd_send_sync(BT_HCI_OP_IO_CAPABILITY_REPLY, resp_buf, NULL); bt_conn_unref(conn); } @@ -2956,7 +2956,7 @@ static void le_ltk_request(struct net_buf *buf) * * Both legacy STK and LE SC LTK have rand and ediv equal to zero. */ - if (evt->rand == 0 && evt->ediv == 0 && bt_smp_get_tk(conn, tk)) { + if (evt->rand == 0U && evt->ediv == 0U && bt_smp_get_tk(conn, tk)) { buf = bt_hci_cmd_create(BT_HCI_OP_LE_LTK_REQ_REPLY, sizeof(*cp)); if (!buf) { @@ -2982,7 +2982,7 @@ static void le_ltk_request(struct net_buf *buf) } if (conn->le.keys && (conn->le.keys->keys & BT_KEYS_LTK_P256) && - evt->rand == 0 && evt->ediv == 0) { + evt->rand == 0U && evt->ediv == 0U) { buf = bt_hci_cmd_create(BT_HCI_OP_LE_LTK_REQ_REPLY, sizeof(*cp)); if (!buf) { @@ -3290,7 +3290,7 @@ void bt_data_parse(struct net_buf_simple *ad, u8_t len; len = net_buf_simple_pull_u8(ad); - if (len == 0) { + if (len == 0U) { /* Early termination */ return; } @@ -5593,7 +5593,7 @@ struct net_buf *bt_buf_get_cmd_complete(s32_t timeout) if (buf) { bt_buf_set_type(buf, BT_BUF_EVT); - buf->len = 0; + buf->len = 0U; net_buf_reserve(buf, CONFIG_BT_HCI_RESERVE); return buf; diff --git a/subsys/bluetooth/host/hci_ecc.c b/subsys/bluetooth/host/hci_ecc.c index a68ce908c53..683c06412da 100644 --- a/subsys/bluetooth/host/hci_ecc.c +++ b/subsys/bluetooth/host/hci_ecc.c @@ -92,7 +92,7 @@ static void send_cmd_status(u16_t opcode, u8_t status) hdr->len = sizeof(*evt); evt = net_buf_add(buf, sizeof(*evt)); - evt->ncmd = 1; + evt->ncmd = 1U; evt->opcode = sys_cpu_to_le16(opcode); evt->status = status; @@ -192,7 +192,7 @@ static void emulate_le_generate_dhkey(void) evt->status = BT_HCI_ERR_UNSPECIFIED; (void)memset(evt->dhkey, 0, sizeof(evt->dhkey)); } else { - evt->status = 0; + evt->status = 0U; /* Convert from big-endian (provided by crypto API) to * little-endian HCI. */ diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 936d74bed2a..e36ae345eb8 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -245,7 +245,7 @@ destroy: #if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL) /* Reset internal members of common channel */ bt_l2cap_chan_set_state(chan, BT_L2CAP_DISCONNECTED); - chan->psm = 0; + chan->psm = 0U; #endif if (chan->destroy) { @@ -719,7 +719,7 @@ static void l2cap_chan_destroy(struct bt_l2cap_chan *chan) if (ch->_sdu) { net_buf_unref(ch->_sdu); ch->_sdu = NULL; - ch->_sdu_len = 0; + ch->_sdu_len = 0U; } } @@ -978,7 +978,7 @@ static void le_conn_rsp(struct bt_l2cap *l2cap, u8_t ident, k_delayed_work_cancel(&chan->chan.rtx_work); /* Reset ident since it got a response */ - chan->chan.ident = 0; + chan->chan.ident = 0U; switch (result) { case BT_L2CAP_LE_SUCCESS: @@ -1498,7 +1498,7 @@ static void l2cap_chan_le_recv_seg(struct bt_l2cap_le_chan *chan, buf = chan->_sdu; chan->_sdu = NULL; - chan->_sdu_len = 0; + chan->_sdu_len = 0U; l2cap_chan_le_recv_sdu(chan, buf, seg); } diff --git a/subsys/bluetooth/host/l2cap_br.c b/subsys/bluetooth/host/l2cap_br.c index 95e7dabf410..b6143f9edb4 100644 --- a/subsys/bluetooth/host/l2cap_br.c +++ b/subsys/bluetooth/host/l2cap_br.c @@ -664,7 +664,7 @@ static int l2cap_br_conn_req_reply(struct bt_l2cap_chan *chan, u16_t result) l2cap_br_send_conn_rsp(chan->conn, BR_CHAN(chan)->tx.cid, BR_CHAN(chan)->rx.cid, chan->ident, result); - chan->ident = 0; + chan->ident = 0U; return 0; } @@ -1310,7 +1310,7 @@ static void l2cap_br_conn_rsp(struct bt_l2cap_br *l2cap, u8_t ident, switch (result) { case BT_L2CAP_BR_SUCCESS: - chan->ident = 0; + chan->ident = 0U; BR_CHAN(chan)->tx.cid = dcid; l2cap_br_conf(chan); bt_l2cap_chan_set_state(chan, BT_L2CAP_CONFIG); diff --git a/subsys/bluetooth/host/mesh/access.c b/subsys/bluetooth/host/mesh/access.c index 05106338efe..717467d4de9 100644 --- a/subsys/bluetooth/host/mesh/access.c +++ b/subsys/bluetooth/host/mesh/access.c @@ -80,7 +80,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod) switch (mod->pub->period >> 6) { case 0x00: /* 1 step is 100 ms */ - period = K_MSEC((mod->pub->period & BIT_MASK(6)) * 100); + period = K_MSEC((mod->pub->period & BIT_MASK(6)) * 100U); break; case 0x01: /* 1 step is 1 second */ @@ -88,11 +88,11 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod) break; case 0x02: /* 1 step is 10 seconds */ - period = K_SECONDS((mod->pub->period & BIT_MASK(6)) * 10); + period = K_SECONDS((mod->pub->period & BIT_MASK(6)) * 10U); break; case 0x03: /* 1 step is 10 minutes */ - period = K_MINUTES((mod->pub->period & BIT_MASK(6)) * 10); + period = K_MINUTES((mod->pub->period & BIT_MASK(6)) * 10U); break; default: CODE_UNREACHABLE; @@ -198,7 +198,7 @@ static void mod_publish(struct k_work *work) if (err) { BT_ERR("Failed to retransmit (err %d)", err); - pub->count = 0; + pub->count = 0U; /* Continue with normal publication */ if (period_ms) { @@ -707,7 +707,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) err = model_send(model, &tx, true, &sdu, &pub_sent_cb, model); if (err) { /* Don't try retransmissions for this publish attempt */ - pub->count = 0; + pub->count = 0U; /* Make sure the publish timer gets reset */ publish_sent(err, model); return err; diff --git a/subsys/bluetooth/host/mesh/adv.c b/subsys/bluetooth/host/mesh/adv.c index 92402fcdb1e..91a0aed4993 100644 --- a/subsys/bluetooth/host/mesh/adv.c +++ b/subsys/bluetooth/host/mesh/adv.c @@ -119,7 +119,7 @@ static inline void adv_send(struct net_buf *buf) if (IS_ENABLED(CONFIG_BT_MESH_DEBUG_USE_ID_ADDR)) { param.options = BT_LE_ADV_OPT_USE_IDENTITY; } else { - param.options = 0; + param.options = 0U; } param.id = BT_ID_DEFAULT; @@ -267,7 +267,7 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi, len = net_buf_simple_pull_u8(buf); /* Check for early termination */ - if (len == 0) { + if (len == 0U) { return; } diff --git a/subsys/bluetooth/host/mesh/cfg_cli.c b/subsys/bluetooth/host/mesh/cfg_cli.c index abdf60c11f7..0061a09d66e 100644 --- a/subsys/bluetooth/host/mesh/cfg_cli.c +++ b/subsys/bluetooth/host/mesh/cfg_cli.c @@ -245,7 +245,7 @@ static void mod_app_status(struct bt_mesh_model *model, elem_addr = net_buf_simple_pull_le16(buf); mod_app_idx = net_buf_simple_pull_le16(buf); - if (buf->len >= 4) { + if (buf->len >= 4U) { cid = net_buf_simple_pull_le16(buf); } else { cid = CID_NVAL; @@ -373,7 +373,7 @@ static void mod_sub_status(struct bt_mesh_model *model, elem_addr = net_buf_simple_pull_le16(buf); sub_addr = net_buf_simple_pull_le16(buf); - if (buf->len >= 4) { + if (buf->len >= 4U) { cid = net_buf_simple_pull_le16(buf); } else { cid = CID_NVAL; @@ -507,7 +507,7 @@ static int cli_prepare(void *param, u32_t op) static void cli_reset(void) { - cli->op_pending = 0; + cli->op_pending = 0U; cli->op_param = NULL; } diff --git a/subsys/bluetooth/host/mesh/cfg_srv.c b/subsys/bluetooth/host/mesh/cfg_srv.c index 7bc6eb2cbc9..69841380940 100644 --- a/subsys/bluetooth/host/mesh/cfg_srv.c +++ b/subsys/bluetooth/host/mesh/cfg_srv.c @@ -104,7 +104,7 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem, int i; if (net_buf_simple_tailroom(buf) < - 4 + (elem->model_count * 2) + (elem->vnd_model_count * 2)) { + 4 + (elem->model_count * 2U) + (elem->vnd_model_count * 2U)) { BT_ERR("Too large device composition"); return -E2BIG; } @@ -182,7 +182,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model, bt_hex(buf->data, buf->len)); page = net_buf_simple_pull_u8(buf); - if (page != 0) { + if (page != 0U) { BT_WARN("Composition page %u not available", page); page = 0U; } @@ -266,12 +266,12 @@ static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr, } model->pub->addr = BT_MESH_ADDR_UNASSIGNED; - model->pub->key = 0; - model->pub->cred = 0; - model->pub->ttl = 0; - model->pub->period = 0; - model->pub->retransmit = 0; - model->pub->count = 0; + model->pub->key = 0U; + model->pub->cred = 0U; + model->pub->ttl = 0U; + model->pub->period = 0U; + model->pub->retransmit = 0U; + model->pub->count = 0U; if (model->pub->update) { k_delayed_work_cancel(&model->pub->timer); @@ -1068,7 +1068,7 @@ static void mod_pub_get(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -1135,7 +1135,7 @@ static void mod_pub_set(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -1284,7 +1284,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); pub_addr = 0U; status = STATUS_INVALID_ADDRESS; goto send_status; @@ -1348,7 +1348,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -1428,7 +1428,7 @@ static void mod_sub_add(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -1504,7 +1504,7 @@ static void mod_sub_del(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -1569,7 +1569,7 @@ static void mod_sub_overwrite(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -1636,7 +1636,7 @@ static void mod_sub_del_all(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -1808,7 +1808,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); sub_addr = BT_MESH_ADDR_UNASSIGNED; status = STATUS_INVALID_ADDRESS; goto send_status; @@ -1886,7 +1886,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); sub_addr = BT_MESH_ADDR_UNASSIGNED; status = STATUS_INVALID_ADDRESS; goto send_status; @@ -1953,7 +1953,7 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -2016,7 +2016,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -2056,7 +2056,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -2095,7 +2095,7 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -2279,9 +2279,9 @@ static void hb_pub_disable(struct bt_mesh_cfg_srv *cfg) BT_DBG(""); cfg->hb_pub.dst = BT_MESH_ADDR_UNASSIGNED; - cfg->hb_pub.count = 0; - cfg->hb_pub.ttl = 0; - cfg->hb_pub.period = 0; + cfg->hb_pub.count = 0U; + cfg->hb_pub.ttl = 0U; + cfg->hb_pub.period = 0U; k_delayed_work_cancel(&cfg->hb_pub.timer); } @@ -2501,7 +2501,7 @@ static void mod_app_bind(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -2558,7 +2558,7 @@ static void mod_app_unbind(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_status; } @@ -2611,7 +2611,7 @@ static void mod_app_get(struct bt_mesh_model *model, elem = bt_mesh_elem_find(elem_addr); if (!elem) { mod = NULL; - vnd = (buf->len == 4); + vnd = (buf->len == 4U); status = STATUS_INVALID_ADDRESS; goto send_list; } @@ -3037,7 +3037,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model, cfg->hb_pub.count = hb_pwr2(param->count_log, 1); cfg->hb_pub.ttl = param->ttl; - BT_DBG("period %u ms", hb_pwr2(param->period_log, 1) * 1000); + BT_DBG("period %u ms", hb_pwr2(param->period_log, 1) * 1000U); /* The first Heartbeat message shall be published as soon * as possible after the Heartbeat Publication Period state @@ -3152,8 +3152,8 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, cfg->hb_sub.src = BT_MESH_ADDR_UNASSIGNED; cfg->hb_sub.dst = BT_MESH_ADDR_UNASSIGNED; cfg->hb_sub.min_hops = BT_MESH_TTL_MAX; - cfg->hb_sub.max_hops = 0; - cfg->hb_sub.count = 0; + cfg->hb_sub.max_hops = 0U; + cfg->hb_sub.count = 0U; } period_ms = 0; @@ -3161,9 +3161,9 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, cfg->hb_sub.src = sub_src; cfg->hb_sub.dst = sub_dst; cfg->hb_sub.min_hops = BT_MESH_TTL_MAX; - cfg->hb_sub.max_hops = 0; - cfg->hb_sub.count = 0; - period_ms = hb_pwr2(sub_period, 1) * 1000; + cfg->hb_sub.max_hops = 0U; + cfg->hb_sub.count = 0U; + period_ms = hb_pwr2(sub_period, 1) * 1000U; } /* Let the transport layer know it needs to handle this address */ @@ -3183,7 +3183,7 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, * disabling subscription, but 0x00 for subsequent Get requests. */ if (!period_ms) { - cfg->hb_sub.min_hops = 0; + cfg->hb_sub.min_hops = 0U; } } @@ -3257,11 +3257,11 @@ static void hb_publish(struct k_work *work) return; } - if (cfg->hb_pub.count == 0) { + if (cfg->hb_pub.count == 0U) { return; } - period_ms = hb_pwr2(cfg->hb_pub.period, 1) * 1000; + period_ms = hb_pwr2(cfg->hb_pub.period, 1) * 1000U; if (period_ms && cfg->hb_pub.count > 1) { k_delayed_work_submit(&cfg->hb_pub.timer, period_ms); } diff --git a/subsys/bluetooth/host/mesh/friend.c b/subsys/bluetooth/host/mesh/friend.c index 67d279f9217..19ac1dd5ea6 100644 --- a/subsys/bluetooth/host/mesh/friend.c +++ b/subsys/bluetooth/host/mesh/friend.c @@ -492,7 +492,7 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx, xact = net_buf_simple_pull_u8(buf); - while (buf->len >= 2) { + while (buf->len >= 2U) { friend_sub_add(frnd, net_buf_simple_pull_be16(buf)); } @@ -527,7 +527,7 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx, xact = net_buf_simple_pull_u8(buf); - while (buf->len >= 2) { + while (buf->len >= 2U) { friend_sub_rem(frnd, net_buf_simple_pull_be16(buf)); } @@ -632,7 +632,7 @@ static void friend_clear_sent(int err, void *user_data) k_delayed_work_submit(&frnd->clear.timer, K_SECONDS(frnd->clear.repeat_sec)); - frnd->clear.repeat_sec *= 2; + frnd->clear.repeat_sec *= 2U; } static const struct bt_mesh_send_cb clear_sent_cb = { @@ -871,7 +871,7 @@ init_friend: frnd->num_elem = msg->num_elem; frnd->net_idx = rx->sub->net_idx; frnd->recv_delay = msg->recv_delay; - frnd->poll_to = poll_to * 100; + frnd->poll_to = poll_to * 100U; frnd->lpn_counter = sys_be16_to_cpu(msg->lpn_counter); frnd->clear.frnd = sys_be16_to_cpu(msg->prev_addr); @@ -1009,7 +1009,7 @@ static void friend_timeout(struct k_work *work) .end = buf_send_end, }; - __ASSERT_NO_MSG(frnd->pending_buf == 0); + __ASSERT_NO_MSG(frnd->pending_buf == 0U); BT_DBG("lpn 0x%04x send_last %u last %p", frnd->lpn, frnd->send_last, frnd->last); @@ -1112,7 +1112,7 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd, if (rx->net_if == BT_MESH_NET_IF_LOCAL) { info.ttl = rx->ctx.recv_ttl; } else { - info.ttl = rx->ctx.recv_ttl - 1; + info.ttl = rx->ctx.recv_ttl - 1U; } info.ctl = rx->ctl; @@ -1234,7 +1234,7 @@ void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, int i; if (!rx->friend_match || - (rx->ctx.recv_ttl <= 1 && rx->net_if != BT_MESH_NET_IF_LOCAL) || + (rx->ctx.recv_ttl <= 1U && rx->net_if != BT_MESH_NET_IF_LOCAL) || bt_mesh_friend_get() != BT_MESH_FRIEND_ENABLED) { return; } diff --git a/subsys/bluetooth/host/mesh/health_cli.c b/subsys/bluetooth/host/mesh/health_cli.c index 22be4589a2b..b251e965422 100644 --- a/subsys/bluetooth/host/mesh/health_cli.c +++ b/subsys/bluetooth/host/mesh/health_cli.c @@ -191,7 +191,7 @@ static int cli_prepare(void *param, u32_t op) static void cli_reset(void) { - health_cli->op_pending = 0; + health_cli->op_pending = 0U; health_cli->op_param = NULL; } diff --git a/subsys/bluetooth/host/mesh/health_srv.c b/subsys/bluetooth/host/mesh/health_srv.c index ff31bb42ab3..176d44ea6ce 100644 --- a/subsys/bluetooth/host/mesh/health_srv.c +++ b/subsys/bluetooth/host/mesh/health_srv.c @@ -223,7 +223,7 @@ static void send_attention_status(struct bt_mesh_model *model, u8_t time; time = k_delayed_work_remaining_get(&srv->attn_timer) / 1000; - BT_DBG("%u second%s", time, (time == 1) ? "" : "s"); + BT_DBG("%u second%s", time, (time == 1U) ? "" : "s"); bt_mesh_model_msg_init(&msg, OP_ATTENTION_STATUS); @@ -251,7 +251,7 @@ static void attention_set_unrel(struct bt_mesh_model *model, time = net_buf_simple_pull_u8(buf); - BT_DBG("%u second%s", time, (time == 1) ? "" : "s"); + BT_DBG("%u second%s", time, (time == 1U) ? "" : "s"); bt_mesh_attention(model, time); } @@ -343,7 +343,7 @@ static int health_pub_update(struct bt_mesh_model *mod) count = health_get_current(mod, pub->msg); if (!count) { - pub->period_div = 0; + pub->period_div = 0U; } return 0; @@ -425,7 +425,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time) srv->cb->attn_on(model); } - k_delayed_work_submit(&srv->attn_timer, time * 1000); + k_delayed_work_submit(&srv->attn_timer, time * 1000U); } else { k_delayed_work_cancel(&srv->attn_timer); diff --git a/subsys/bluetooth/host/mesh/main.c b/subsys/bluetooth/host/mesh/main.c index 49f03645e89..dccd76b8ef2 100644 --- a/subsys/bluetooth/host/mesh/main.c +++ b/subsys/bluetooth/host/mesh/main.c @@ -194,7 +194,7 @@ static void model_suspend(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, bool vnd, bool primary, void *user_data) { if (mod->pub && mod->pub->update) { - mod->pub->count = 0; + mod->pub->count = 0U; k_delayed_work_cancel(&mod->pub->timer); } } diff --git a/subsys/bluetooth/host/mesh/net.c b/subsys/bluetooth/host/mesh/net.c index 927e520464f..e13d59b54d3 100644 --- a/subsys/bluetooth/host/mesh/net.c +++ b/subsys/bluetooth/host/mesh/net.c @@ -881,7 +881,7 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, * GATT bearers shall drop all messages with TTL value set to 1." */ if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) && - tx->ctx->send_ttl != 1) { + tx->ctx->send_ttl != 1U) { if (bt_mesh_proxy_relay(&buf->b, tx->ctx->addr) && BT_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { /* Notify completion if this only went @@ -913,7 +913,7 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, cb->end(0, cb_data); } k_work_submit(&bt_mesh.local_work); - } else if (tx->ctx->send_ttl != 1) { + } else if (tx->ctx->send_ttl != 1U) { /* Deliver to to the advertising network interface. Mesh spec * 3.4.5.2: "The output filter of the interface connected to * advertising or GATT bearers shall drop all messages with @@ -1141,11 +1141,11 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, * advertising or GATT bearers shall drop all messages with * TTL value set to 1." */ - if (rx->ctx.recv_ttl == 1) { + if (rx->ctx.recv_ttl == 1U) { return; } } else { - if (rx->ctx.recv_ttl <= 1) { + if (rx->ctx.recv_ttl <= 1U) { return; } } @@ -1179,7 +1179,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, if (rx->net_if != BT_MESH_NET_IF_LOCAL) { /* Leave CTL bit intact */ sbuf->data[1] &= 0x80; - sbuf->data[1] |= rx->ctx.recv_ttl - 1; + sbuf->data[1] |= rx->ctx.recv_ttl - 1U; } net_buf_add_mem(buf, sbuf->data, sbuf->len); @@ -1258,8 +1258,8 @@ int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if, rx->ctx.recv_ttl = TTL(buf->data); /* Default to responding with TTL 0 for non-routed messages */ - if (rx->ctx.recv_ttl == 0) { - rx->ctx.send_ttl = 0; + if (rx->ctx.recv_ttl == 0U) { + rx->ctx.send_ttl = 0U; } else { rx->ctx.send_ttl = BT_MESH_TTL_DEFAULT; } @@ -1340,7 +1340,7 @@ static void ivu_refresh(struct k_work *work) BT_DBG("%s for %u hour%s", atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) ? "IVU in Progress" : "IVU Normal mode", - bt_mesh.ivu_duration, bt_mesh.ivu_duration == 1 ? "" : "s"); + bt_mesh.ivu_duration, bt_mesh.ivu_duration == 1U ? "" : "s"); if (bt_mesh.ivu_duration < BT_MESH_IVU_MIN_HOURS) { if (IS_ENABLED(CONFIG_BT_SETTINGS)) { diff --git a/subsys/bluetooth/host/mesh/prov.c b/subsys/bluetooth/host/mesh/prov.c index 7bdd8d0c64d..f2b2fa6d65b 100644 --- a/subsys/bluetooth/host/mesh/prov.c +++ b/subsys/bluetooth/host/mesh/prov.c @@ -385,7 +385,7 @@ static u8_t last_seg(u8_t len) static inline u8_t next_transaction_id(void) { - if (link.tx.id != 0 && link.tx.id != 0xFF) { + if (link.tx.id != 0U && link.tx.id != 0xFF) { return ++link.tx.id; } @@ -1329,7 +1329,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) } else if (seg == link.rx.last_seg) { u8_t expect_len; - expect_len = (link.rx.buf->len - 20 - + expect_len = (link.rx.buf->len - 20U - (23 * (link.rx.last_seg - 1))); if (expect_len != buf->len) { BT_ERR("Incorrect last seg len: %u != %u", @@ -1398,7 +1398,7 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) return; } - if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->len <= 20) { + if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->len <= 20U) { BT_ERR("Too small total length for multi-segment PDU"); close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED); return; diff --git a/subsys/bluetooth/host/mesh/settings.c b/subsys/bluetooth/host/mesh/settings.c index ad3e38f76da..b29e6f53343 100644 --- a/subsys/bluetooth/host/mesh/settings.c +++ b/subsys/bluetooth/host/mesh/settings.c @@ -440,10 +440,10 @@ static int hb_pub_set(int argc, char **argv, void *val_ctx) if (settings_val_get_len_cb(val_ctx) == 0) { pub->dst = BT_MESH_ADDR_UNASSIGNED; - pub->count = 0; - pub->ttl = 0; - pub->period = 0; - pub->feat = 0; + pub->count = 0U; + pub->ttl = 0U; + pub->period = 0U; + pub->feat = 0U; BT_DBG("Cleared heartbeat publication"); return 0; @@ -464,7 +464,7 @@ static int hb_pub_set(int argc, char **argv, void *val_ctx) if (hb_val.indefinite) { pub->count = 0xffff; } else { - pub->count = 0; + pub->count = 0U; } BT_DBG("Restored heartbeat publication"); @@ -560,12 +560,12 @@ static int mod_set_pub(struct bt_mesh_model *mod, void *val_ctx) if (settings_val_get_len_cb(val_ctx) == 0) { mod->pub->addr = BT_MESH_ADDR_UNASSIGNED; - mod->pub->key = 0; - mod->pub->cred = 0; - mod->pub->ttl = 0; - mod->pub->period = 0; - mod->pub->retransmit = 0; - mod->pub->count = 0; + mod->pub->key = 0U; + mod->pub->cred = 0U; + mod->pub->ttl = 0U; + mod->pub->period = 0U; + mod->pub->retransmit = 0U; + mod->pub->count = 0U; BT_DBG("Cleared publication for model"); return 0; @@ -583,7 +583,7 @@ static int mod_set_pub(struct bt_mesh_model *mod, void *val_ctx) mod->pub->ttl = pub.ttl; mod->pub->period = pub.period; mod->pub->retransmit = pub.retransmit; - mod->pub->count = 0; + mod->pub->count = 0U; BT_DBG("Restored model publication, dst 0x%04x app_idx 0x%03x", pub.addr, pub.key); diff --git a/subsys/bluetooth/host/mesh/shell.c b/subsys/bluetooth/host/mesh/shell.c index ce4de22d744..986c699b5cf 100644 --- a/subsys/bluetooth/host/mesh/shell.c +++ b/subsys/bluetooth/host/mesh/shell.c @@ -393,7 +393,7 @@ static int cmd_static_oob(const struct shell *shell, size_t argc, char *argv[]) { if (argc < 2) { prov.static_val = NULL; - prov.static_val_len = 0; + prov.static_val_len = 0U; } else { prov.static_val_len = hex2bin(argv[1], static_val, 16); if (prov.static_val_len) { @@ -620,7 +620,7 @@ static int cmd_get_comp(const struct shell *shell, size_t argc, char *argv[]) shell_print(shell, "\tElement @ 0x%04x:", loc); - if (comp.len < ((sig * 2) + (vnd * 4))) { + if (comp.len < ((sig * 2U) + (vnd * 4U))) { shell_print(shell, "\t\t...truncated data!"); break; } diff --git a/subsys/bluetooth/host/mesh/transport.c b/subsys/bluetooth/host/mesh/transport.c index dafba9fabfe..e2b39a54bfa 100644 --- a/subsys/bluetooth/host/mesh/transport.c +++ b/subsys/bluetooth/host/mesh/transport.c @@ -338,7 +338,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, seg_o = 0U; tx->dst = net_tx->ctx->addr; - tx->seg_n = (sdu->len - 1) / 12; + tx->seg_n = (sdu->len - 1) / 12U; tx->nack_count = tx->seg_n + 1; tx->seq_auth = SEQ_AUTH(BT_MESH_NET_IVI_TX, bt_mesh.seq); tx->sub = net_tx->sub; @@ -455,7 +455,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, } if (msg->len > 11) { - tx->ctx->send_rel = 1; + tx->ctx->send_rel = 1U; } BT_DBG("net_idx 0x%04x app_idx 0x%04x dst 0x%04x", tx->sub->net_idx, @@ -795,7 +795,7 @@ static int trans_heartbeat(struct bt_mesh_net_rx *rx, BT_DBG("src 0x%04x TTL %u InitTTL %u (%u hop%s) feat 0x%04x", rx->ctx.addr, rx->ctx.recv_ttl, init_ttl, hops, - (hops == 1) ? "" : "s", feat); + (hops == 1U) ? "" : "s", feat); bt_mesh_heartbeat(rx->ctx.addr, rx->ctx.recv_dst, hops, feat); @@ -916,7 +916,7 @@ static inline s32_t ack_timeout(struct seg_rx *rx) to = K_MSEC(150 + (50 * ttl)); /* 100 ms for every not yet received segment */ - to += K_MSEC(((rx->seg_n + 1) - popcount(rx->block)) * 100); + to += K_MSEC(((rx->seg_n + 1) - popcount(rx->block)) * 100U); /* Make sure we don't send more frequently than the duration for * each packet (default is 300ms). diff --git a/subsys/bluetooth/host/rfcomm.c b/subsys/bluetooth/host/rfcomm.c index b30489f4d80..70b8be18a59 100644 --- a/subsys/bluetooth/host/rfcomm.c +++ b/subsys/bluetooth/host/rfcomm.c @@ -1132,7 +1132,7 @@ static void rfcomm_handle_rpn(struct bt_rfcomm_session *session, return; } - if (value_len != 1) { + if (value_len != 1U) { return; } diff --git a/subsys/bluetooth/host/sdp.c b/subsys/bluetooth/host/sdp.c index 222d9ce2900..82d5b2cee7d 100644 --- a/subsys/bluetooth/host/sdp.c +++ b/subsys/bluetooth/host/sdp.c @@ -358,19 +358,19 @@ static u32_t search_uuid(struct bt_sdp_data_elem *elem, struct bt_uuid *uuid, cur_elem = elem->data; if ((elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_UUID_UNSPEC) { - if (seq_size == 2) { + if (seq_size == 2U) { u.uuid.type = BT_UUID_TYPE_16; u.u16.val = *((u16_t *)cur_elem); if (!bt_uuid_cmp(&u.uuid, uuid)) { *found = true; } - } else if (seq_size == 4) { + } else if (seq_size == 4U) { u.uuid.type = BT_UUID_TYPE_32; u.u32.val = *((u32_t *)cur_elem); if (!bt_uuid_cmp(&u.uuid, uuid)) { *found = true; } - } else if (seq_size == 16) { + } else if (seq_size == 16U) { u.uuid.type = BT_UUID_TYPE_128; memcpy(u.u128.val, cur_elem, seq_size); if (!bt_uuid_cmp(&u.uuid, uuid)) { @@ -506,13 +506,13 @@ static u16_t find_services(struct net_buf *buf, return BT_SDP_INVALID_SYNTAX; } - if (data_elem.data_size == 2) { + if (data_elem.data_size == 2U) { u.uuid.type = BT_UUID_TYPE_16; u.u16.val = net_buf_pull_be16(buf); - } else if (data_elem.data_size == 4) { + } else if (data_elem.data_size == 4U) { u.uuid.type = BT_UUID_TYPE_32; u.u32.val = net_buf_pull_be32(buf); - } else if (data_elem.data_size == 16) { + } else if (data_elem.data_size == 16U) { u.uuid.type = BT_UUID_TYPE_128; sys_memcpy_swap(u.u128.val, buf->data, data_elem.data_size); @@ -723,7 +723,7 @@ static u32_t copy_attribute(struct bt_sdp_data_elem *elem, /* Copy the header */ net_buf_add_u8(buf, elem->type); - switch (total_size - (seq_size + 1)) { + switch (total_size - (seq_size + 1U)) { case 1: net_buf_add_u8(buf, elem->data_size); break; @@ -749,11 +749,11 @@ static u32_t copy_attribute(struct bt_sdp_data_elem *elem, } else if ((elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_UINT8 || (elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_INT8 || (elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_UUID_UNSPEC) { - if (seq_size == 1) { + if (seq_size == 1U) { net_buf_add_u8(buf, *((u8_t *)elem->data)); - } else if (seq_size == 2) { + } else if (seq_size == 2U) { net_buf_add_be16(buf, *((u16_t *)elem->data)); - } else if (seq_size == 4) { + } else if (seq_size == 4U) { net_buf_add_be32(buf, *((u32_t *)elem->data)); } else { /* TODO: Convert 32bit and 128bit values to big-endian*/ @@ -1010,13 +1010,13 @@ static u16_t get_att_search_list(struct net_buf *buf, u32_t *filter, } /* This is an attribute ID */ - if (data_elem.data_size == 2) { + if (data_elem.data_size == 2U) { filter[(*num_filters)++] = 0xffff0000 | net_buf_pull_be16(buf); } /* This is an attribute ID range */ - if (data_elem.data_size == 4) { + if (data_elem.data_size == 4U) { filter[(*num_filters)++] = net_buf_pull_be32(buf); } @@ -1541,7 +1541,7 @@ static int sdp_client_ssa_search(struct bt_sdp_client *session) * server so far, otherwise use the original state taken from remote's * last response PDU that is cached by SDP client context. */ - if (session->cstate.length == 0) { + if (session->cstate.length == 0U) { net_buf_add_u8(buf, 0x00); } else { net_buf_add_u8(buf, session->cstate.length); @@ -1604,17 +1604,17 @@ static u16_t sdp_client_get_total(struct bt_sdp_client *session, * was sent. For subsequent calls related to the same SSA request input * buf and in/out function parameters stays neutral. */ - if (session->cstate.length == 0) { + if (session->cstate.length == 0U) { seq = net_buf_pull_u8(buf); pulled = 1U; switch (seq) { case BT_SDP_SEQ8: *total = net_buf_pull_u8(buf); - pulled += 1; + pulled += 1U; break; case BT_SDP_SEQ16: *total = net_buf_pull_be16(buf); - pulled += 2; + pulled += 2U; break; default: BT_WARN("Sequence type 0x%02x not handled", seq); @@ -1786,8 +1786,8 @@ static int sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf) * current response frame has Continuation State shortest and * valid and this is the first response frame as well. */ - if (frame_len == 2 && cstate->length == 0 && - session->cstate.length == 0) { + if (frame_len == 2U && cstate->length == 0U && + session->cstate.length == 0U) { BT_DBG("record for UUID 0x%s not found", bt_uuid_str(session->param->uuid)); /* Call user UUID handler */ diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index f6a33f7833b..d7e8938edff 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -2948,7 +2948,7 @@ static u8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf) case PASSKEY_DISPLAY: case PASSKEY_INPUT: smp->passkey_round++; - if (smp->passkey_round == 20) { + if (smp->passkey_round == 20U) { break; } @@ -2999,7 +2999,7 @@ static u8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf) smp_send_pairing_random(smp); smp->passkey_round++; - if (smp->passkey_round == 20) { + if (smp->passkey_round == 20U) { atomic_set_bit(&smp->allowed_cmds, BT_SMP_DHKEY_CHECK); atomic_set_bit(smp->flags, SMP_FLAG_DHCHECK_WAIT); return 0; diff --git a/subsys/bluetooth/shell/bredr.c b/subsys/bluetooth/shell/bredr.c index 9aafbefced5..545cfc6fd29 100644 --- a/subsys/bluetooth/shell/bredr.c +++ b/subsys/bluetooth/shell/bredr.c @@ -174,7 +174,7 @@ static int cmd_discovery(const struct shell *shell, size_t argc, char *argv[]) struct bt_br_discovery_param param; param.limited = false; - param.length = 8; + param.length = 8U; if (argc > 2) { param.length = atoi(argv[2]); @@ -274,7 +274,7 @@ static int cmd_l2cap_register(const struct shell *shell, if (bt_l2cap_br_server_register(&br_server) < 0) { shell_error(shell, "Unable to register psm"); - br_server.psm = 0; + br_server.psm = 0U; return -ENOEXEC; } else { shell_print(shell, "L2CAP psm %u registered", br_server.psm); diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index 984cda8bc9e..4b8428330f8 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -250,7 +250,7 @@ static int hexstr2array(const char *str, u8_t *array, u8_t size) int i, j; u8_t tmp; - if (strlen(str) != ((size * 2) + (size - 1))) { + if (strlen(str) != ((size * 2U) + (size - 1))) { return -EINVAL; } @@ -675,7 +675,7 @@ static int cmd_advertise(const struct shell *shell, size_t argc, char *argv[]) } else if (!strcmp(argv[1], "scan")) { param.options = BT_LE_ADV_OPT_USE_NAME; } else if (!strcmp(argv[1], "nconn")) { - param.options = 0; + param.options = 0U; } else { goto fail; } diff --git a/subsys/bluetooth/shell/gatt.c b/subsys/bluetooth/shell/gatt.c index 9a924a85d53..85f762d9b49 100644 --- a/subsys/bluetooth/shell/gatt.c +++ b/subsys/bluetooth/shell/gatt.c @@ -31,7 +31,7 @@ static void exchange_func(struct bt_conn *conn, u8_t err, struct bt_gatt_exchange_params *params) { - shell_print(ctx_shell, "Exchange %s", err == 0 ? "successful" : + shell_print(ctx_shell, "Exchange %s", err == 0U ? "successful" : "failed"); } @@ -228,7 +228,7 @@ static int cmd_read(const struct shell *shell, size_t argc, char *argv[]) read_params.func = read_func; read_params.handle_count = 1; read_params.single.handle = strtoul(argv[1], NULL, 16); - read_params.single.offset = 0; + read_params.single.offset = 0U; if (argc > 2) { read_params.single.offset = strtoul(argv[2], NULL, 16); @@ -309,7 +309,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char *argv[]) gatt_write_buf[0] = strtoul(argv[3], NULL, 16); write_params.data = gatt_write_buf; - write_params.length = 1; + write_params.length = 1U; write_params.handle = handle; write_params.offset = offset; write_params.func = write_func; @@ -409,7 +409,7 @@ static u8_t notify_func(struct bt_conn *conn, { if (!data) { shell_print(ctx_shell, "Unsubscribed"); - params->value_handle = 0; + params->value_handle = 0U; return BT_GATT_ITER_STOP; } @@ -711,7 +711,7 @@ static ssize_t write_met(struct bt_conn *conn, const struct bt_gatt_attr *attr, } else { write_count++; write_len += len; - write_rate = ((u64_t)write_len << 3) * 1000000000 / delta; + write_rate = ((u64_t)write_len << 3) * 1000000000U / delta; } return len; diff --git a/subsys/bluetooth/shell/hci.c b/subsys/bluetooth/shell/hci.c index 8311d22215d..9c37f494db9 100644 --- a/subsys/bluetooth/shell/hci.c +++ b/subsys/bluetooth/shell/hci.c @@ -41,19 +41,19 @@ int cmd_mesh_adv(const struct shell *shell, size_t argc, char *argv[]) /* TODO: fetch and fill cmdline params */ cp = net_buf_add(buf, sizeof(*cp)); - cp->adv_slot = 0; + cp->adv_slot = 0U; cp->own_addr_type = 0x01; memset(&cp->random_addr, 0, sizeof(bt_addr_t)); cp->ch_map = 0x07; cp->tx_power = 0; - cp->min_tx_delay = 0; + cp->min_tx_delay = 0U; cp->max_tx_delay = 0x32; cp->retx_count = 0x07; cp->retx_interval = 0x00; cp->scan_delay = 0x0a; cp->scan_duration = sys_cpu_to_le16(0x0064); cp->scan_filter = 0x00; - cp->data_len = 0; + cp->data_len = 0U; memset(cp->data, 0, sizeof(cp->data)); } else if (!strcmp(argv[1], "off")) { struct bt_hci_cp_mesh_advertise_cancel *cp; @@ -68,7 +68,7 @@ int cmd_mesh_adv(const struct shell *shell, size_t argc, char *argv[]) net_buf_add_u8(buf, BT_HCI_OC_MESH_ADVERTISE_CANCEL); cp = net_buf_add(buf, sizeof(*cp)); - cp->adv_slot = 0; + cp->adv_slot = 0U; } else { return -EINVAL; } diff --git a/subsys/bluetooth/shell/l2cap.c b/subsys/bluetooth/shell/l2cap.c index 0e3cbac3eef..9440e768653 100644 --- a/subsys/bluetooth/shell/l2cap.c +++ b/subsys/bluetooth/shell/l2cap.c @@ -73,7 +73,7 @@ static int l2cap_recv_metrics(struct bt_l2cap_chan *chan, struct net_buf *buf) cycle_stamp = k_cycle_get_32(); } else { len += buf->len; - l2cap_rate = ((u64_t)len << 3) * 1000000000 / delta; + l2cap_rate = ((u64_t)len << 3) * 1000000000U / delta; } return 0; @@ -245,7 +245,7 @@ static int cmd_register(const struct shell *shell, size_t argc, char *argv[]) if (bt_l2cap_server_register(&server) < 0) { shell_error(shell, "Unable to register psm"); - server.psm = 0; + server.psm = 0U; return -ENOEXEC; } else { bt_conn_cb_register(&l2cap_conn_callbacks); diff --git a/subsys/bluetooth/shell/rfcomm.c b/subsys/bluetooth/shell/rfcomm.c index 7d342c557e1..99cc0511897 100644 --- a/subsys/bluetooth/shell/rfcomm.c +++ b/subsys/bluetooth/shell/rfcomm.c @@ -157,7 +157,7 @@ static int cmd_register(const struct shell *shell, size_t argc, char *argv[]) ret = bt_rfcomm_server_register(&rfcomm_server); if (ret < 0) { shell_error(shell, "Unable to register channel %x", ret); - rfcomm_server.channel = 0; + rfcomm_server.channel = 0U; return -ENOEXEC; } else { shell_print(shell, "RFCOMM channel %u registered", diff --git a/subsys/console/tty.c b/subsys/console/tty.c index f14762031ec..c3ab0a75d0c 100644 --- a/subsys/console/tty.c +++ b/subsys/console/tty.c @@ -39,7 +39,7 @@ static void tty_uart_isr(void *user_data) } else { uart_fifo_fill(dev, &tty->tx_ringbuf[tty->tx_get++], 1); if (tty->tx_get >= tty->tx_ringbuf_sz) { - tty->tx_get = 0; + tty->tx_get = 0U; } k_sem_give(&tty->tx_sem); } @@ -102,7 +102,7 @@ ssize_t tty_write(struct tty_serial *tty, const void *buf, size_t size) size_t out_size = 0; int res = 0; - if (tty->tx_ringbuf_sz == 0) { + if (tty->tx_ringbuf_sz == 0U) { /* Unbuffered operation, implicitly blocking. */ out_size = size; @@ -151,7 +151,7 @@ static int tty_getchar(struct tty_serial *tty) key = irq_lock(); c = tty->rx_ringbuf[tty->rx_get++]; if (tty->rx_get >= tty->rx_ringbuf_sz) { - tty->rx_get = 0; + tty->rx_get = 0U; } irq_unlock(key); @@ -186,7 +186,7 @@ static ssize_t tty_read_unbuf(struct tty_serial *tty, void *buf, size_t size) size--; } - if (size == 0 || (timeout != K_FOREVER && timeout-- == 0)) { + if (size == 0 || (timeout != K_FOREVER && timeout-- == 0U)) { break; } @@ -207,7 +207,7 @@ ssize_t tty_read(struct tty_serial *tty, void *buf, size_t size) size_t out_size = 0; int res = 0; - if (tty->rx_ringbuf_sz == 0) { + if (tty->rx_ringbuf_sz == 0U) { return tty_read_unbuf(tty, buf, size); } @@ -242,11 +242,11 @@ int tty_init(struct tty_serial *tty, struct device *uart_dev) /* We start in unbuffer mode. */ tty->rx_ringbuf = NULL; - tty->rx_ringbuf_sz = 0; + tty->rx_ringbuf_sz = 0U; tty->tx_ringbuf = NULL; - tty->tx_ringbuf_sz = 0; + tty->tx_ringbuf_sz = 0U; - tty->rx_get = tty->rx_put = tty->tx_get = tty->tx_put = 0; + tty->rx_get = tty->rx_put = tty->tx_get = tty->tx_put = 0U; tty->rx_timeout = K_FOREVER; tty->tx_timeout = K_FOREVER; diff --git a/subsys/cpp/cpp_ctors.c b/subsys/cpp/cpp_ctors.c index 5912ce92d57..f0264850f6e 100644 --- a/subsys/cpp/cpp_ctors.c +++ b/subsys/cpp/cpp_ctors.c @@ -37,7 +37,7 @@ void __do_global_ctors_aux(void) nCtors = (unsigned int)__CTOR_LIST__[0]; - while (nCtors >= 1) { + while (nCtors >= 1U) { __CTOR_LIST__[nCtors--](); } } diff --git a/subsys/dfu/boot/mcuboot.c b/subsys/dfu/boot/mcuboot.c index 121b8628ecf..d6c0be890d2 100644 --- a/subsys/dfu/boot/mcuboot.c +++ b/subsys/dfu/boot/mcuboot.c @@ -339,7 +339,7 @@ int boot_read_bank_header(u8_t area_id, * - image_flags: skip (all unsupported or not relevant) * - version: include */ - header->mcuboot_version = 1; + header->mcuboot_version = 1U; header->h.v1.image_size = v1_raw.image_size; sem_ver = &header->h.v1.sem_ver; sem_ver->major = v1_raw.version.major; @@ -437,15 +437,15 @@ int mcuboot_swap_type(void) for (i = 0; i < BOOT_SWAP_TABLES_COUNT; i++) { table = boot_swap_tables + i; - if ((table->magic_slot0 == 0 || + if ((table->magic_slot0 == 0U || table->magic_slot0 == state_slot0.magic) && - (table->magic_slot1 == 0 || + (table->magic_slot1 == 0U || table->magic_slot1 == state_slot1.magic) && - (table->image_ok_slot0 == 0 || + (table->image_ok_slot0 == 0U || table->image_ok_slot0 == state_slot0.image_ok) && - (table->image_ok_slot1 == 0 || + (table->image_ok_slot1 == 0U || table->image_ok_slot1 == state_slot1.image_ok) && - (table->copy_done_slot0 == 0 || + (table->copy_done_slot0 == 0U || table->copy_done_slot0 == state_slot0.copy_done)) { assert(table->swap_type == BOOT_SWAP_TYPE_TEST || diff --git a/subsys/dfu/img_util/flash_img.c b/subsys/dfu/img_util/flash_img.c index 9cb422ffc2e..055801e9c4a 100644 --- a/subsys/dfu/img_util/flash_img.c +++ b/subsys/dfu/img_util/flash_img.c @@ -75,7 +75,7 @@ static int flash_sync(struct flash_img_context *ctx) } ctx->bytes_written += ctx->buf_bytes; - ctx->buf_bytes = 0; + ctx->buf_bytes = 0U; return rc; } @@ -136,7 +136,7 @@ size_t flash_img_bytes_written(struct flash_img_context *ctx) int flash_img_init(struct flash_img_context *ctx) { ctx->bytes_written = 0; - ctx->buf_bytes = 0; + ctx->buf_bytes = 0U; return flash_area_open(DT_FLASH_AREA_IMAGE_1_ID, (const struct flash_area **)&(ctx->flash_area)); } diff --git a/subsys/disk/disk_access_sdhc.c b/subsys/disk/disk_access_sdhc.c index 51595897718..7460c0623df 100644 --- a/subsys/disk/disk_access_sdhc.c +++ b/subsys/disk/disk_access_sdhc.c @@ -194,7 +194,7 @@ static int sdhc_map_flags(const struct sdhc_flag_map *map, int flags) return flags; } - for (; map->mask != 0; map++) { + for (; map->mask != 0U; map++) { if ((flags & map->mask) == map->mask) { return -map->err; } @@ -253,7 +253,7 @@ static bool sdhc_retry_ok(struct sdhc_retry *retry) if (retry->tries < SDHC_MIN_TRIES) { retry->tries++; - if (retry->sleep != 0) { + if (retry->sleep != 0U) { k_sleep(retry->sleep); } @@ -746,7 +746,7 @@ static int sdhc_detect(struct sdhc_data *data) return err; } - if ((ocr & SDHC_CCS) == 0) { + if ((ocr & SDHC_CCS) == 0U) { /* A 'SDSC' card */ return -ENOTSUP; } @@ -824,7 +824,7 @@ static int sdhc_read(struct sdhc_data *data, u8_t *buf, u32_t sector, } /* Read the sectors */ - for (; count != 0; count--) { + for (; count != 0U; count--) { err = sdhc_rx_block(data, buf, SDHC_SECTOR_SIZE); if (err != 0) { goto error; @@ -858,7 +858,7 @@ static int sdhc_write(struct sdhc_data *data, const u8_t *buf, u32_t sector, sdhc_set_cs(data, 0); /* Write the blocks one-by-one */ - for (; count != 0; count--) { + for (; count != 0U; count--) { err = sdhc_cmd_r1(data, SDHC_WRITE_BLOCK, sector); if (err < 0) { goto error; diff --git a/subsys/fb/cfb.c b/subsys/fb/cfb.c index 71b968aa14d..4ad0b10a992 100644 --- a/subsys/fb/cfb.c +++ b/subsys/fb/cfb.c @@ -60,7 +60,7 @@ static inline u8_t *get_glyph_ptr(const struct cfb_font *fptr, char c) if (fptr->caps & CFB_FONT_MONO_VPACKED) { return (u8_t *)fptr->data + (c - fptr->first_char) * - (fptr->width * fptr->height / 8); + (fptr->width * fptr->height / 8U); } return NULL; @@ -86,16 +86,16 @@ static u8_t draw_char_vtmono(const struct char_framebuffer *fb, } for (size_t g_x = 0; g_x < fptr->width; g_x++) { - u32_t y_segment = y / 8; + u32_t y_segment = y / 8U; - for (size_t g_y = 0; g_y < fptr->height / 8; g_y++) { + for (size_t g_y = 0; g_y < fptr->height / 8U; g_y++) { u32_t fb_y = (y_segment + g_y) * fb->x_res; if ((fb_y + x + g_x) >= fb->size) { return 0; } fb->buf[fb_y + x + g_x] = - glyph_ptr[g_x * (fptr->height / 8) + g_y]; + glyph_ptr[g_x * (fptr->height / 8U) + g_y]; } } @@ -139,7 +139,7 @@ static int cfb_reverse_bytes(const struct char_framebuffer *fb) return -1; } - for (size_t i = 0; i < fb->x_res * fb->y_res / 8; i++) { + for (size_t i = 0; i < fb->x_res * fb->y_res / 8U; i++) { fb->buf[i] = (fb->buf[i] & 0xf0) >> 4 | (fb->buf[i] & 0x0f) << 4; fb->buf[i] = (fb->buf[i] & 0xcc) >> 2 | @@ -153,7 +153,7 @@ static int cfb_reverse_bytes(const struct char_framebuffer *fb) static int cfb_invert(const struct char_framebuffer *fb) { - for (size_t i = 0; i < fb->x_res * fb->y_res / 8; i++) { + for (size_t i = 0; i < fb->x_res * fb->y_res / 8U; i++) { fb->buf[i] = ~fb->buf[i]; } diff --git a/subsys/fs/fcb/fcb.c b/subsys/fs/fcb/fcb.c index 25c76b93326..cbd953bb01c 100644 --- a/subsys/fs/fcb/fcb.c +++ b/subsys/fs/fcb/fcb.c @@ -109,7 +109,7 @@ fcb_init(int f_area_id, struct fcb *fcb) } align = fcb_get_align(fcb); - if (align == 0) { + if (align == 0U) { return FCB_ERR_ARGS; } diff --git a/subsys/fs/fcb/fcb_getnext.c b/subsys/fs/fcb/fcb_getnext.c index 8f0ccf79071..fc9d2fa0974 100644 --- a/subsys/fs/fcb/fcb_getnext.c +++ b/subsys/fs/fcb/fcb_getnext.c @@ -51,7 +51,7 @@ fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc) */ loc->fe_sector = fcb->f_oldest; } - if (loc->fe_elem_off == 0) { + if (loc->fe_elem_off == 0U) { /* * If offset is zero, we serve the first entry from the sector. */ diff --git a/subsys/fs/fcb/fcb_priv.h b/subsys/fs/fcb/fcb_priv.h index dfe2480e171..bfd4de05c2b 100644 --- a/subsys/fs/fcb/fcb_priv.h +++ b/subsys/fs/fcb/fcb_priv.h @@ -29,10 +29,10 @@ int fcb_get_len(u8_t *buf, u16_t *len); static inline int fcb_len_in_flash(struct fcb *fcb, u16_t len) { - if (fcb->f_align <= 1) { + if (fcb->f_align <= 1U) { return len; } - return (len + (fcb->f_align - 1)) & ~(fcb->f_align - 1); + return (len + (fcb->f_align - 1U)) & ~(fcb->f_align - 1U); } const struct flash_area *fcb_open_flash(const struct fcb *fcb); diff --git a/subsys/fs/fcb/fcb_walk.c b/subsys/fs/fcb/fcb_walk.c index 336dab337f5..1df7e942070 100644 --- a/subsys/fs/fcb/fcb_walk.c +++ b/subsys/fs/fcb/fcb_walk.c @@ -20,7 +20,7 @@ fcb_walk(struct fcb *fcb, struct flash_sector *sector, fcb_walk_cb cb, int rc; entry_ctx.loc.fe_sector = sector; - entry_ctx.loc.fe_elem_off = 0; + entry_ctx.loc.fe_elem_off = 0U; rc = k_mutex_lock(&fcb->f_mtx, K_FOREVER); if (rc < 0) { diff --git a/subsys/fs/nvs/nvs.c b/subsys/fs/nvs/nvs.c index c40ce6b38d7..32c5d3be97e 100644 --- a/subsys/fs/nvs/nvs.c +++ b/subsys/fs/nvs/nvs.c @@ -21,10 +21,10 @@ LOG_MODULE_REGISTER(fs_nvs, CONFIG_NVS_LOG_LEVEL); /* _nvs_al_size returns size aligned to fs->write_block_size */ static inline size_t _nvs_al_size(struct nvs_fs *fs, size_t len) { - if (fs->write_block_size <= 1) { + if (fs->write_block_size <= 1U) { return len; } - return (len + (fs->write_block_size - 1)) & ~(fs->write_block_size - 1); + return (len + (fs->write_block_size - 1U)) & ~(fs->write_block_size - 1U); } /* end basic routines */ @@ -53,7 +53,7 @@ static int _nvs_flash_al_wrt(struct nvs_fs *fs, u32_t addr, const void *data, /* flash protection set error */ return rc; } - blen = len & ~(fs->write_block_size - 1); + blen = len & ~(fs->write_block_size - 1U); if (blen > 0) { rc = flash_write(fs->flash_device, offset, data8, blen); if (rc) { @@ -142,7 +142,7 @@ static int _nvs_flash_block_cmp(struct nvs_fs *fs, u32_t addr, const void *data, size_t bytes_to_cmp, block_size; u8_t buf[NVS_BLOCK_SIZE]; - block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1); + block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1U); while (len) { bytes_to_cmp = MIN(block_size, len); rc = _nvs_flash_rd(fs, addr, buf, bytes_to_cmp); @@ -171,7 +171,7 @@ static int _nvs_flash_cmp_const(struct nvs_fs *fs, u32_t addr, u8_t value, size_t bytes_to_cmp, block_size; u8_t cmp[NVS_BLOCK_SIZE]; - block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1); + block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1U); (void)memset(cmp, value, block_size); while (len) { bytes_to_cmp = MIN(block_size, len); @@ -194,7 +194,7 @@ static int _nvs_flash_block_move(struct nvs_fs *fs, u32_t addr, size_t len) size_t bytes_to_copy, block_size; u8_t buf[NVS_BLOCK_SIZE]; - block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1); + block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1U); while (len) { bytes_to_copy = MIN(block_size, len); @@ -340,7 +340,7 @@ static int _nvs_prev_ate(struct nvs_fs *fs, u32_t *addr, struct nvs_ate *ate) } /* last ate in sector, do jump to previous sector */ - if (((*addr) >> ADDR_SECT_SHIFT) == 0) { + if (((*addr) >> ADDR_SECT_SHIFT) == 0U) { *addr += ((fs->sector_count - 1) << ADDR_SECT_SHIFT); } else { *addr -= (1 << ADDR_SECT_SHIFT); @@ -410,7 +410,7 @@ static int _nvs_sector_close(struct nvs_fs *fs) ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); close_ate.id = 0xFFFF; - close_ate.len = 0; + close_ate.len = 0U; close_ate.offset = (u16_t)((fs->ate_wra + ate_size) & ADDR_OFFS_MASK); fs->ate_wra &= ADDR_SECT_MASK; @@ -767,7 +767,7 @@ ssize_t nvs_write(struct nvs_fs *fs, u16_t id, const void *data, size_t len) if (len == 0) { /* do not try to compare with empty data */ - if (wlk_ate.len == 0) { + if (wlk_ate.len == 0U) { return 0; } } else { @@ -865,7 +865,7 @@ ssize_t nvs_read_hist(struct nvs_fs *fs, u16_t id, void *data, size_t len, } if (((wlk_addr == fs->ate_wra) && (wlk_ate.id != id)) || - (wlk_ate.len == 0) || (cnt_his < cnt)) { + (wlk_ate.len == 0U) || (cnt_his < cnt)) { return -ENOENT; } diff --git a/subsys/logging/log_backend_net.c b/subsys/logging/log_backend_net.c index 9d7c782da90..277c7b0957e 100644 --- a/subsys/logging/log_backend_net.c +++ b/subsys/logging/log_backend_net.c @@ -87,13 +87,13 @@ static int do_net_init(void) if (IS_ENABLED(CONFIG_NET_IPV4) && server_addr.sa_family == AF_INET) { local_addr = (struct sockaddr *)&local_addr4; server_addr_len = sizeof(struct sockaddr_in); - local_addr4.sin_port = 0; + local_addr4.sin_port = 0U; } if (IS_ENABLED(CONFIG_NET_IPV6) && server_addr.sa_family == AF_INET6) { local_addr = (struct sockaddr *)&local_addr6; server_addr_len = sizeof(struct sockaddr_in6); - local_addr6.sin6_port = 0; + local_addr6.sin6_port = 0U; } if (local_addr == NULL) { diff --git a/subsys/logging/log_msg.c b/subsys/logging/log_msg.c index d06cd903a48..0884e2c976b 100644 --- a/subsys/logging/log_msg.c +++ b/subsys/logging/log_msg.c @@ -163,7 +163,7 @@ static struct log_msg *msg_alloc(u32_t nargs) return msg; } - msg->hdr.params.std.nargs = 0; + msg->hdr.params.std.nargs = 0U; msg->hdr.params.generic.ext = 1; n -= LOG_MSG_NARGS_HEAD_CHUNK; next = &msg->payload.ext.next; @@ -201,7 +201,7 @@ static void copy_args_to_msg(struct log_msg *msg, u32_t *args, u32_t nargs) nargs = 0U; } - while (nargs != 0) { + while (nargs != 0U) { u32_t cpy_args = MIN(nargs, ARGS_CONT_MSG); (void)memcpy(cont->payload.args, args, diff --git a/subsys/logging/log_output.c b/subsys/logging/log_output.c index 3bb2958c3fc..a79f9c969f9 100644 --- a/subsys/logging/log_output.c +++ b/subsys/logging/log_output.c @@ -68,22 +68,22 @@ static int level_to_rfc5424_severity(u32_t level) switch (level) { case LOG_LEVEL_NONE: - ret = 7; + ret = 7U; break; case LOG_LEVEL_ERR: - ret = 3; + ret = 3U; break; case LOG_LEVEL_WRN: - ret = 4; + ret = 4U; break; case LOG_LEVEL_INF: - ret = 6; + ret = 6U; break; case LOG_LEVEL_DBG: - ret = 7; + ret = 7U; break; default: - ret = 7; + ret = 7U; break; } @@ -157,7 +157,7 @@ static int timestamp_print(const struct log_output *log_output, if (!format) { length = print_formatted(log_output, "[%08lu] ", timestamp); - } else if (freq != 0) { + } else if (freq != 0U) { u32_t remainder; u32_t seconds; u32_t hours; @@ -167,13 +167,13 @@ static int timestamp_print(const struct log_output *log_output, timestamp /= timestamp_div; seconds = timestamp / freq; - hours = seconds / 3600; - seconds -= hours * 3600; - mins = seconds / 60; - seconds -= mins * 60; + hours = seconds / 3600U; + seconds -= hours * 3600U; + mins = seconds / 60U; + seconds -= mins * 60U; remainder = timestamp % freq; - ms = (remainder * 1000) / freq; + ms = (remainder * 1000U) / freq; us = (1000 * (1000 * remainder - (ms * freq))) / freq; if (IS_ENABLED(CONFIG_LOG_BACKEND_NET) && @@ -189,11 +189,11 @@ static int timestamp_print(const struct log_output *log_output, strftime(time_str, sizeof(time_str), "%FT%T", tm); length = print_formatted(log_output, "%s.%06dZ ", - time_str, ms * 1000 + us); + time_str, ms * 1000U + us); #else length = print_formatted(log_output, "1970-01-01T%02d:%02d:%02d.%06dZ ", - hours, mins, seconds, ms * 1000 + us); + hours, mins, seconds, ms * 1000U + us); #endif } else { length = print_formatted(log_output, @@ -255,11 +255,11 @@ static void newline_print(const struct log_output *ctx, u32_t flags) return; } - if ((flags & LOG_OUTPUT_FLAG_CRLF_NONE) != 0) { + if ((flags & LOG_OUTPUT_FLAG_CRLF_NONE) != 0U) { return; } - if ((flags & LOG_OUTPUT_FLAG_CRLF_LFONLY) != 0) { + if ((flags & LOG_OUTPUT_FLAG_CRLF_LFONLY) != 0U) { print_formatted(ctx, "\n"); } else { print_formatted(ctx, "\r\n"); @@ -443,7 +443,7 @@ static u32_t prefix_print(const struct log_output *log_output, u32_t flags, bool func_on, u32_t timestamp, u8_t level, u8_t domain_id, u16_t source_id) { - u32_t length = 0; + u32_t length = 0U; bool stamp = flags & LOG_OUTPUT_FLAG_TIMESTAMP; bool colors_on = flags & LOG_OUTPUT_FLAG_COLORS; @@ -629,8 +629,8 @@ void log_output_timestamp_freq_set(u32_t frequency) * printed) and too high frequency leads to overflows in calculations. */ while (frequency > 1000000) { - frequency /= 2; - timestamp_div *= 2; + frequency /= 2U; + timestamp_div *= 2U; } freq = frequency; diff --git a/subsys/mgmt/serial_util.c b/subsys/mgmt/serial_util.c index 30d953150f3..1d283b69d2c 100644 --- a/subsys/mgmt/serial_util.c +++ b/subsys/mgmt/serial_util.c @@ -104,7 +104,7 @@ struct net_buf *mcumgr_serial_process_frag( break; case MCUMGR_SERIAL_HDR_FRAG: - if (rx_ctxt->nb->len == 0) { + if (rx_ctxt->nb->len == 0U) { mcumgr_serial_free_rx_ctxt(rx_ctxt); return NULL; } @@ -142,13 +142,13 @@ struct net_buf *mcumgr_serial_process_frag( } crc = mcumgr_serial_calc_crc(rx_ctxt->nb->data, rx_ctxt->nb->len); - if (crc != 0) { + if (crc != 0U) { mcumgr_serial_free_rx_ctxt(rx_ctxt); return NULL; } /* Packet is complete; strip the CRC. */ - rx_ctxt->nb->len -= 2; + rx_ctxt->nb->len -= 2U; nb = rx_ctxt->nb; rx_ctxt->nb = NULL; diff --git a/subsys/mgmt/smp.c b/subsys/mgmt/smp.c index 162d44a2a90..0cdc9dd7f10 100644 --- a/subsys/mgmt/smp.c +++ b/subsys/mgmt/smp.c @@ -175,7 +175,7 @@ zephyr_smp_tx_rsp(struct smp_streamer *ns, void *rsp, void *arg) nb = rsp; mtu = zst->zst_get_mtu(rsp); - if (mtu == 0) { + if (mtu == 0U) { /* The transport cannot support a transmission right now. */ return MGMT_ERR_EUNKNOWN; } diff --git a/subsys/net/buf.c b/subsys/net/buf.c index 4b38a3c9898..0abff02a5e7 100644 --- a/subsys/net/buf.c +++ b/subsys/net/buf.c @@ -78,7 +78,7 @@ static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool, void net_buf_reset(struct net_buf *buf) { - NET_BUF_ASSERT(buf->flags == 0); + NET_BUF_ASSERT(buf->flags == 0U); NET_BUF_ASSERT(buf->frags == NULL); net_buf_simple_reset(&buf->b); @@ -330,8 +330,8 @@ success: buf->__buf = NULL; } - buf->ref = 1; - buf->flags = 0; + buf->ref = 1U; + buf->flags = 0U; buf->frags = NULL; buf->size = size; net_buf_reset(buf); @@ -430,7 +430,7 @@ struct net_buf *net_buf_get(struct k_fifo *fifo, s32_t timeout) void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve) { NET_BUF_ASSERT(buf); - NET_BUF_ASSERT(buf->len == 0); + NET_BUF_ASSERT(buf->len == 0U); NET_BUF_DBG("buf %p reserve %zu", buf, reserve); buf->data = buf->__buf + reserve; diff --git a/subsys/net/ip/6lo.c b/subsys/net/ip/6lo.c index 515002f3585..c524f500497 100644 --- a/subsys/net/ip/6lo.c +++ b/subsys/net/ip/6lo.c @@ -203,8 +203,8 @@ static inline u8_t compress_tfl(struct net_ipv6_hdr *ipv6, tcl = ((ipv6->vtc & 0x0F) << 4) | ((ipv6->tcflow & 0xF0) >> 4); tcl = (tcl << 6) | (tcl >> 2); /* ECN(2), DSCP(6) */ - if (((ipv6->tcflow & 0x0F) == 0) && (ipv6->flow == 0)) { - if (((ipv6->vtc & 0x0F) == 0) && ((ipv6->tcflow & 0xF0) == 0)) { + if (((ipv6->tcflow & 0x0F) == 0U) && (ipv6->flow == 0U)) { + if (((ipv6->vtc & 0x0F) == 0U) && ((ipv6->tcflow & 0xF0) == 0U)) { NET_DBG("Trafic class and Flow label elided"); /* Trafic class and Flow label elided */ @@ -217,7 +217,7 @@ static inline u8_t compress_tfl(struct net_ipv6_hdr *ipv6, IPHC[offset++] = tcl; } } else { - if (((ipv6->vtc & 0x0F) == 0) && (ipv6->tcflow & 0x30)) { + if (((ipv6->vtc & 0x0F) == 0U) && (ipv6->tcflow & 0x30)) { NET_DBG("ECN + 2-bit Pad + Flow Label, DSCP is elided"); /* ECN + 2-bit Pad + Flow Label, DSCP is elided.*/ @@ -225,7 +225,7 @@ static inline u8_t compress_tfl(struct net_ipv6_hdr *ipv6, IPHC[offset++] = (tcl & 0xC0) | (ipv6->tcflow & 0x0F); memcpy(&IPHC[offset], &ipv6->flow, 2); - offset += 2; + offset += 2U; } else { NET_DBG("ECN + DSCP + 4-bit Pad + Flow Label"); @@ -237,7 +237,7 @@ static inline u8_t compress_tfl(struct net_ipv6_hdr *ipv6, IPHC[offset++] = ipv6->tcflow & 0x0F; memcpy(&IPHC[offset], &ipv6->flow, 2); - offset += 2; + offset += 2U; } } @@ -311,7 +311,7 @@ static inline u8_t compress_sa(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_SAM_10; memcpy(&IPHC[offset], &ipv6->src.s6_addr[14], 2); - offset += 2; + offset += 2U; } else { if (!net_pkt_lladdr_src(pkt)) { NET_ERR("Invalid src ll address"); @@ -331,7 +331,7 @@ static inline u8_t compress_sa(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_SAM_01; memcpy(&IPHC[offset], &ipv6->src.s6_addr[8], 8); - offset += 8; + offset += 8U; } } } else { @@ -367,7 +367,7 @@ static inline u8_t compress_sa_ctx(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_SAM_10; memcpy(&IPHC[offset], &ipv6->src.s6_addr[14], 2); - offset += 2; + offset += 2U; } else if (net_ipv6_addr_based_on_ll(&ipv6->src, net_pkt_lladdr_src(pkt))) { NET_DBG("SAM_11 src address is fully elided"); @@ -381,7 +381,7 @@ static inline u8_t compress_sa_ctx(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_SAM_01; memcpy(&IPHC[offset], &ipv6->src.s6_addr[8], 8); - offset += 8; + offset += 8U; } return offset; @@ -416,7 +416,7 @@ static inline u8_t compress_da_mcast(struct net_ipv6_hdr *ipv6, offset++; memcpy(&IPHC[offset], &ipv6->dst.s6_addr[13], 3); - offset += 3; + offset += 3U; } else if (net_6lo_maddr_48_bit_compressible(&ipv6->dst)) { NET_DBG("DAM_01 6 bytes: 2nd byte + last five bytes"); @@ -427,13 +427,13 @@ static inline u8_t compress_da_mcast(struct net_ipv6_hdr *ipv6, offset++; memcpy(&IPHC[offset], &ipv6->dst.s6_addr[11], 5); - offset += 5; + offset += 5U; } else { NET_DBG("DAM_00 dst complete addr inlined"); /* complete address IPHC[1] |= NET_6LO_IPHC_DAM_00 */ memcpy(&IPHC[offset], &ipv6->dst.s6_addr[0], 16); - offset += 16; + offset += 16U; } return offset; @@ -463,7 +463,7 @@ static inline u8_t compress_da(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_DAM_10; memcpy(&IPHC[offset], &ipv6->dst.s6_addr[14], 2); - offset += 2; + offset += 2U; } else { if (!net_pkt_lladdr_dst(pkt)) { NET_ERR("Invalid dst ll address"); @@ -483,7 +483,7 @@ static inline u8_t compress_da(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_DAM_01; memcpy(&IPHC[offset], &ipv6->dst.s6_addr[8], 8); - offset += 8; + offset += 8U; } } } else { @@ -491,7 +491,7 @@ static inline u8_t compress_da(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_DAM_00; memcpy(&IPHC[offset], &ipv6->dst.s6_addr[0], 16); - offset += 16; + offset += 16U; } return offset; @@ -517,7 +517,7 @@ static inline u8_t compress_da_ctx(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_DAM_10; memcpy(&IPHC[offset], &ipv6->dst.s6_addr[14], 2); - offset += 2; + offset += 2U; } else { if (net_ipv6_addr_based_on_ll(&ipv6->dst, net_pkt_lladdr_dst(pkt))) { @@ -532,7 +532,7 @@ static inline u8_t compress_da_ctx(struct net_ipv6_hdr *ipv6, IPHC[1] |= NET_6LO_IPHC_DAM_01; memcpy(&IPHC[offset], &ipv6->dst.s6_addr[8], 8); - offset += 8; + offset += 8U; } } @@ -591,7 +591,7 @@ static inline u8_t compress_nh_udp(struct net_udp_hdr *udp, offset++; memcpy(&IPHC[offset], &udp->src_port, 2); - offset += 2; + offset += 2U; IPHC[offset++] = (u8_t)(htons(udp->dst_port)); } else if (((htons(udp->src_port) >> 8) & 0xFF) == @@ -607,19 +607,19 @@ static inline u8_t compress_nh_udp(struct net_udp_hdr *udp, IPHC[offset++] = (u8_t)(htons(udp->src_port)); memcpy(&IPHC[offset], &udp->dst_port, 2); - offset += 2; + offset += 2U; } else { NET_DBG("Can not compress ports, ports are inlined"); /* can not compress ports, ports are inlined */ offset++; memcpy(&IPHC[offset], &udp->src_port, 4); - offset += 4; + offset += 4U; } /* All 16 bits of udp chksum are inlined, length is elided */ memcpy(&IPHC[offset], &udp->chksum, 2); - offset += 2; + offset += 2U; return offset; } @@ -809,10 +809,10 @@ static inline u8_t uncompress_tfl(struct net_pkt *pkt, ipv6->tcflow = ((tcl & 0x0F) << 4) | (CIPHC[offset + 1] & 0x0F); - memcpy(&ipv6->flow, &CIPHC[offset + 2], 2); + memcpy(&ipv6->flow, &CIPHC[offset + 2U], 2); } - offset += 4; + offset += 4U; break; case NET_6LO_IPHC_TF_01: NET_DBG("ECN + 2-bit Pad + Flow Label, DSCP is elided"); @@ -825,7 +825,7 @@ static inline u8_t uncompress_tfl(struct net_pkt *pkt, memcpy(&ipv6->flow, &CIPHC[offset + 1], 2); } - offset += 3; + offset += 3U; break; case NET_6LO_IPHC_TF_10: NET_DBG("Flow label elided"); @@ -836,7 +836,7 @@ static inline u8_t uncompress_tfl(struct net_pkt *pkt, ipv6->vtc |= ((tcl & 0xF0) >> 4); ipv6->tcflow = (tcl & 0x0F) << 4; - ipv6->flow = 0; + ipv6->flow = 0U; } offset++; @@ -845,8 +845,8 @@ static inline u8_t uncompress_tfl(struct net_pkt *pkt, NET_DBG("Tcl and Flow label elided"); if (!dry_run) { - ipv6->tcflow = 0; - ipv6->flow = 0; + ipv6->tcflow = 0U; + ipv6->flow = 0U; } break; @@ -870,19 +870,19 @@ static inline u8_t uncompress_hoplimit(struct net_pkt *pkt, break; case NET_6LO_IPHC_HLIM1: if (!dry_run) { - ipv6->hop_limit = 1; + ipv6->hop_limit = 1U; } break; case NET_6LO_IPHC_HLIM64: if (!dry_run) { - ipv6->hop_limit = 64; + ipv6->hop_limit = 64U; } break; case NET_6LO_IPHC_HLIM255: if (!dry_run) { - ipv6->hop_limit = 255; + ipv6->hop_limit = 255U; } break; @@ -907,7 +907,7 @@ static inline u8_t uncompress_sa(struct net_pkt *pkt, memcpy(ipv6->src.s6_addr, &CIPHC[offset], 16); } - offset += 16; + offset += 16U; break; case NET_6LO_IPHC_SAM_01: NET_DBG("SAM_01 last 64 bits are inlined"); @@ -919,7 +919,7 @@ static inline u8_t uncompress_sa(struct net_pkt *pkt, memcpy(&ipv6->src.s6_addr[8], &CIPHC[offset], 8); } - offset += 8; + offset += 8U; break; case NET_6LO_IPHC_SAM_10: NET_DBG("SAM_10 src addr 16 bit compressed"); @@ -933,7 +933,7 @@ static inline u8_t uncompress_sa(struct net_pkt *pkt, memcpy(&ipv6->src.s6_addr[14], &CIPHC[offset], 2); } - offset += 2; + offset += 2U; break; case NET_6LO_IPHC_SAM_11: NET_DBG("SAM_11 generate src addr from ll"); @@ -969,7 +969,7 @@ static inline u8_t uncompress_sa_ctx(struct net_pkt *pkt, memcpy(&ipv6->src.s6_addr[8], &CIPHC[offset], 8); } - offset += 8; + offset += 8U; break; case NET_6LO_IPHC_SAM_10: @@ -987,7 +987,7 @@ static inline u8_t uncompress_sa_ctx(struct net_pkt *pkt, memcpy(&ipv6->src.s6_addr[14], &CIPHC[offset], 2); } - offset += 2; + offset += 2U; break; case NET_6LO_IPHC_SAM_11: @@ -1043,7 +1043,7 @@ static inline u8_t uncompress_da_mcast(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[0], &CIPHC[offset], 16); } - offset += 16; + offset += 16U; break; case NET_6LO_IPHC_DAM_01: NET_DBG("DAM_01 2nd byte and last five bytes"); @@ -1055,7 +1055,7 @@ static inline u8_t uncompress_da_mcast(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[11], &CIPHC[offset + 1], 5); } - offset += 6; + offset += 6U; break; case NET_6LO_IPHC_DAM_10: NET_DBG("DAM_10 2nd byte and last three bytes"); @@ -1067,7 +1067,7 @@ static inline u8_t uncompress_da_mcast(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[13], &CIPHC[offset + 1], 3); } - offset += 4; + offset += 4U; break; case NET_6LO_IPHC_DAM_11: NET_DBG("DAM_11 8 bit compressed"); @@ -1105,7 +1105,7 @@ static inline u8_t uncompress_da(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[0], &CIPHC[offset], 16); } - offset += 16; + offset += 16U; break; case NET_6LO_IPHC_DAM_01: NET_DBG("DAM_01 last 64 bits are inlined"); @@ -1117,7 +1117,7 @@ static inline u8_t uncompress_da(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[8], &CIPHC[offset], 8); } - offset += 8; + offset += 8U; break; case NET_6LO_IPHC_DAM_10: NET_DBG("DAM_10 dst addr 16 bit compressed"); @@ -1131,7 +1131,7 @@ static inline u8_t uncompress_da(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[14], &CIPHC[offset], 2); } - offset += 2; + offset += 2U; break; case NET_6LO_IPHC_DAM_11: NET_DBG("DAM_11 generate dst addr from ll"); @@ -1173,7 +1173,7 @@ static inline u8_t uncompress_da_ctx(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[8], &CIPHC[offset], 8); } - offset += 8; + offset += 8U; break; case NET_6LO_IPHC_DAM_10: @@ -1191,7 +1191,7 @@ static inline u8_t uncompress_da_ctx(struct net_pkt *pkt, memcpy(&ipv6->dst.s6_addr[14], &CIPHC[offset], 2); } - offset += 2; + offset += 2U; break; case NET_6LO_IPHC_DAM_11: @@ -1240,10 +1240,10 @@ static inline u8_t uncompress_nh_udp(struct net_pkt *pkt, if (!dry_run) { memcpy(&udp->src_port, &CIPHC[offset], 2); - memcpy(&udp->dst_port, &CIPHC[offset + 2], 2); + memcpy(&udp->dst_port, &CIPHC[offset + 2U], 2); } - offset += 4; + offset += 4U; break; case NET_6LO_NHC_UDP_PORT_01: NET_DBG("src full, dst 8 bits inlined"); @@ -1251,10 +1251,10 @@ static inline u8_t uncompress_nh_udp(struct net_pkt *pkt, if (!dry_run) { memcpy(&udp->src_port, &CIPHC[offset], 2); udp->dst_port = htons(((u16_t)NET_6LO_NHC_UDP_8_BIT_PORT - << 8) | CIPHC[offset + 2]); + << 8) | CIPHC[offset + 2U]); } - offset += 3; + offset += 3U; break; case NET_6LO_NHC_UDP_PORT_10: NET_DBG("src 8 bits, dst full inlined"); @@ -1265,7 +1265,7 @@ static inline u8_t uncompress_nh_udp(struct net_pkt *pkt, memcpy(&udp->dst_port, &CIPHC[offset + 1], 2); } - offset += 3; + offset += 3U; break; case NET_6LO_NHC_UDP_PORT_11: NET_DBG("src and dst 4 bits inlined"); @@ -1462,7 +1462,7 @@ static bool uncompress_IPHC_header(struct net_pkt *pkt, memcpy(&udp->chksum, &CIPHC[offset], 2); } - offset += 2; + offset += 2U; } if (!dry_run) { @@ -1542,8 +1542,8 @@ static inline bool uncompress_ipv6_header(struct net_pkt *pkt) struct net_buf *frag = pkt->frags; /* Pull off IPv6 dispatch header and adjust data and length */ - memmove(frag->data, frag->data + 1, frag->len - 1); - frag->len -= 1; + memmove(frag->data, frag->data + 1, frag->len - 1U); + frag->len -= 1U; return true; } diff --git a/subsys/net/ip/connection.c b/subsys/net/ip/connection.c index fcc1eb1cf15..3d0e28fd4c6 100644 --- a/subsys/net/ip/connection.c +++ b/subsys/net/ip/connection.c @@ -823,14 +823,14 @@ enum net_verdict net_conn_input(struct net_pkt *pkt, return NET_DROP; } - src_port = dst_port = 0; + src_port = dst_port = 0U; } else if (IS_ENABLED(CONFIG_NET_SOCKETS_CAN) && net_pkt_family(pkt) == AF_CAN) { if (proto != CAN_RAW) { return NET_DROP; } - src_port = dst_port = 0; + src_port = dst_port = 0U; } else { NET_DBG("No suitable protocol handler configured"); return NET_DROP; diff --git a/subsys/net/ip/dhcpv4.c b/subsys/net/ip/dhcpv4.c index 6ea44f3b8a9..c1bb0cc947c 100644 --- a/subsys/net/ip/dhcpv4.c +++ b/subsys/net/ip/dhcpv4.c @@ -378,11 +378,11 @@ static void dhcpv4_update_timeout_work(u32_t timeout) static void dhcpv4_enter_selecting(struct net_if *iface) { - iface->config.dhcpv4.attempts = 0; + iface->config.dhcpv4.attempts = 0U; - iface->config.dhcpv4.lease_time = 0; - iface->config.dhcpv4.renewal_time = 0; - iface->config.dhcpv4.rebinding_time = 0; + iface->config.dhcpv4.lease_time = 0U; + iface->config.dhcpv4.renewal_time = 0U; + iface->config.dhcpv4.rebinding_time = 0U; iface->config.dhcpv4.state = NET_DHCPV4_SELECTING; NET_DBG("enter state=%s", @@ -421,7 +421,7 @@ static bool dhcpv4_renewal_timedout(struct net_if *iface, s64_t timeout) iface->config.dhcpv4.state = NET_DHCPV4_RENEWING; NET_DBG("enter state=%s", net_dhcpv4_state_name(iface->config.dhcpv4.state)); - iface->config.dhcpv4.attempts = 0; + iface->config.dhcpv4.attempts = 0U; return true; } @@ -437,14 +437,14 @@ static bool dhcpv4_rebinding_timedout(struct net_if *iface, s64_t timeout) iface->config.dhcpv4.state = NET_DHCPV4_REBINDING; NET_DBG("enter state=%s", net_dhcpv4_state_name(iface->config.dhcpv4.state)); - iface->config.dhcpv4.attempts = 0; + iface->config.dhcpv4.attempts = 0U; return true; } static void dhcpv4_enter_requesting(struct net_if *iface) { - iface->config.dhcpv4.attempts = 0; + iface->config.dhcpv4.attempts = 0U; iface->config.dhcpv4.state = NET_DHCPV4_REQUESTING; NET_DBG("enter state=%s", net_dhcpv4_state_name(iface->config.dhcpv4.state)); @@ -460,14 +460,14 @@ static void dhcpv4_enter_bound(struct net_if *iface) renewal_time = iface->config.dhcpv4.renewal_time; if (!renewal_time) { /* The default renewal time rfc2131 4.4.5 */ - renewal_time = iface->config.dhcpv4.lease_time / 2; + renewal_time = iface->config.dhcpv4.lease_time / 2U; iface->config.dhcpv4.renewal_time = renewal_time; } rebinding_time = iface->config.dhcpv4.rebinding_time; if (!rebinding_time) { /* The default rebinding time rfc2131 4.4.5 */ - rebinding_time = iface->config.dhcpv4.lease_time * 875 / 1000; + rebinding_time = iface->config.dhcpv4.lease_time * 875U / 1000; iface->config.dhcpv4.rebinding_time = rebinding_time; } @@ -604,7 +604,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, case DHCPV4_OPTIONS_SUBNET_MASK: { struct in_addr netmask; - if (length != 4) { + if (length != 4U) { NET_ERR("options_subnet_mask, bad length"); return false; } @@ -628,13 +628,13 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, * of preference. Hence we choose the first * and skip the rest. */ - if (length % 4 != 0 || length < 4) { + if (length % 4 != 0U || length < 4) { NET_ERR("options_router, bad length"); return false; } if (net_pkt_read(pkt, router.s4_addr, 4) || - net_pkt_skip(pkt, length - 4)) { + net_pkt_skip(pkt, length - 4U)) { NET_ERR("options_router, short packet"); return false; } @@ -658,7 +658,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, * of preference. Hence we choose the first * and skip the rest. */ - if (length % 4 != 0) { + if (length % 4 != 0U) { NET_ERR("options_dns, bad length"); return false; } @@ -666,7 +666,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, (void)memset(&dns, 0, sizeof(dns)); if (net_pkt_read(pkt, dns.sin_addr.s4_addr, 4) || - net_pkt_skip(pkt, length - 4)) { + net_pkt_skip(pkt, length - 4U)) { NET_ERR("options_dns, short packet"); return false; } @@ -686,7 +686,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, } #endif case DHCPV4_OPTIONS_LEASE_TIME: - if (length != 4) { + if (length != 4U) { NET_ERR("options_lease_time, bad length"); return false; } @@ -703,7 +703,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, break; case DHCPV4_OPTIONS_RENEWAL: - if (length != 4) { + if (length != 4U) { NET_DBG("options_renewal, bad length"); return false; } @@ -720,7 +720,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, break; case DHCPV4_OPTIONS_REBINDING: - if (length != 4) { + if (length != 4U) { NET_DBG("options_rebinding, bad length"); return false; } @@ -738,7 +738,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, break; case DHCPV4_OPTIONS_SERVER_ID: - if (length != 4) { + if (length != 4U) { NET_DBG("options_server_id, bad length"); return false; } @@ -756,7 +756,7 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt, &iface->config.dhcpv4.server_id))); break; case DHCPV4_OPTIONS_MSG_TYPE: { - if (length != 1) { + if (length != 1U) { NET_DBG("options_msg_type, bad length"); return false; } @@ -986,7 +986,7 @@ static void dhcpv4_iface_event_handler(struct net_mgmt_event_callback *cb, NET_DBG("Interface %p going down", iface); if (iface->config.dhcpv4.state == NET_DHCPV4_BOUND) { - iface->config.dhcpv4.attempts = 0; + iface->config.dhcpv4.attempts = 0U; iface->config.dhcpv4.state = NET_DHCPV4_RENEWING; NET_DBG("enter state=%s", net_dhcpv4_state_name( iface->config.dhcpv4.state)); @@ -1000,7 +1000,7 @@ static void dhcpv4_iface_event_handler(struct net_mgmt_event_callback *cb, * which will then call dhcpv4_send_request() automatically. */ iface->config.dhcpv4.timer_start = k_uptime_get() - 1; - iface->config.dhcpv4.request_time = 0; + iface->config.dhcpv4.request_time = 0U; k_delayed_work_cancel(&timeout_work); k_delayed_work_submit(&timeout_work, K_NO_WAIT); @@ -1034,12 +1034,12 @@ void net_dhcpv4_start(struct net_if *iface) NET_DBG("iface %p state=%s", iface, net_dhcpv4_state_name(iface->config.dhcpv4.state)); - iface->config.dhcpv4.attempts = 0; - iface->config.dhcpv4.lease_time = 0; - iface->config.dhcpv4.renewal_time = 0; + iface->config.dhcpv4.attempts = 0U; + iface->config.dhcpv4.lease_time = 0U; + iface->config.dhcpv4.renewal_time = 0U; - iface->config.dhcpv4.server_id.s_addr = 0; - iface->config.dhcpv4.requested_ip.s_addr = 0; + iface->config.dhcpv4.server_id.s_addr = 0U; + iface->config.dhcpv4.requested_ip.s_addr = 0U; /* We need entropy for both an XID and a random delay * before sending the initial discover message. diff --git a/subsys/net/ip/icmpv4.c b/subsys/net/ip/icmpv4.c index 0cfab016ffa..c9973b8e2fd 100644 --- a/subsys/net/ip/icmpv4.c +++ b/subsys/net/ip/icmpv4.c @@ -38,7 +38,7 @@ static int icmpv4_create(struct net_pkt *pkt, u8_t icmp_type, u8_t icmp_code) icmp_hdr->type = icmp_type; icmp_hdr->code = icmp_code; - icmp_hdr->chksum = 0; + icmp_hdr->chksum = 0U; return net_pkt_set_data(pkt, &icmpv4_access); } @@ -297,7 +297,7 @@ enum net_verdict net_icmpv4_input(struct net_pkt *pkt, return NET_DROP; } - if (net_calc_chksum_icmpv4(pkt) != 0) { + if (net_calc_chksum_icmpv4(pkt) != 0U) { NET_DBG("DROP: Invalid checksum"); goto drop; } @@ -318,7 +318,7 @@ enum net_verdict net_icmpv4_input(struct net_pkt *pkt, SYS_SLIST_FOR_EACH_CONTAINER(&handlers, cb, node) { if (cb->type == icmp_hdr->type && - (cb->code == icmp_hdr->code || cb->code == 0)) { + (cb->code == icmp_hdr->code || cb->code == 0U)) { return cb->handler(pkt, ip_hdr); } } diff --git a/subsys/net/ip/icmpv6.c b/subsys/net/ip/icmpv6.c index 2276a3edd0b..8d9d0f7f8f3 100644 --- a/subsys/net/ip/icmpv6.c +++ b/subsys/net/ip/icmpv6.c @@ -97,7 +97,7 @@ int net_icmpv6_create(struct net_pkt *pkt, u8_t icmp_type, u8_t icmp_code) icmp_hdr->type = icmp_type; icmp_hdr->code = icmp_code; - icmp_hdr->chksum = 0; + icmp_hdr->chksum = 0U; return net_pkt_set_data(pkt, &icmp_access); } @@ -369,7 +369,7 @@ enum net_verdict net_icmpv6_input(struct net_pkt *pkt, return NET_DROP; } - if (net_calc_chksum_icmpv6(pkt) != 0) { + if (net_calc_chksum_icmpv6(pkt) != 0U) { NET_DBG("DROP: invalid checksum"); goto drop; } @@ -384,7 +384,7 @@ enum net_verdict net_icmpv6_input(struct net_pkt *pkt, SYS_SLIST_FOR_EACH_CONTAINER(&handlers, cb, node) { if (cb->type == icmp_hdr->type && - (cb->code == icmp_hdr->code || cb->code == 0)) { + (cb->code == icmp_hdr->code || cb->code == 0U)) { return cb->handler(pkt, ip_hdr, icmp_hdr); } } diff --git a/subsys/net/ip/ipv4.c b/subsys/net/ip/ipv4.c index f9d1f4e9411..59cac7dc12a 100644 --- a/subsys/net/ip/ipv4.c +++ b/subsys/net/ip/ipv4.c @@ -41,19 +41,19 @@ int net_ipv4_create(struct net_pkt *pkt, ipv4_hdr->vhl = 0x45; ipv4_hdr->tos = 0x00; - ipv4_hdr->len = 0; - ipv4_hdr->id[0] = 0; - ipv4_hdr->id[1] = 0; - ipv4_hdr->offset[0] = 0; - ipv4_hdr->offset[1] = 0; + ipv4_hdr->len = 0U; + ipv4_hdr->id[0] = 0U; + ipv4_hdr->id[1] = 0U; + ipv4_hdr->offset[0] = 0U; + ipv4_hdr->offset[1] = 0U; ipv4_hdr->ttl = net_pkt_ipv4_ttl(pkt); - if (ipv4_hdr->ttl == 0) { + if (ipv4_hdr->ttl == 0U) { ipv4_hdr->ttl = net_if_ipv4_get_ttl(net_pkt_iface(pkt)); } - ipv4_hdr->proto = 0; - ipv4_hdr->chksum = 0; + ipv4_hdr->proto = 0U; + ipv4_hdr->chksum = 0U; net_ipaddr_copy(&ipv4_hdr->dst, dst); net_ipaddr_copy(&ipv4_hdr->src, src); @@ -132,7 +132,7 @@ enum net_verdict net_ipv4_input(struct net_pkt *pkt) goto drop; } - hdr_len = (hdr->vhl & NET_IPV4_IHL_MASK) * 4; + hdr_len = (hdr->vhl & NET_IPV4_IHL_MASK) * 4U; if (hdr_len < sizeof(struct net_ipv4_hdr)) { NET_DBG("DROP: Invalid hdr length"); goto drop; @@ -160,7 +160,7 @@ enum net_verdict net_ipv4_input(struct net_pkt *pkt) } if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) && - net_calc_chksum_ipv4(pkt) != 0) { + net_calc_chksum_ipv4(pkt) != 0U) { NET_DBG("DROP: invalid chksum"); goto drop; } diff --git a/subsys/net/ip/ipv4_autoconf.c b/subsys/net/ip/ipv4_autoconf.c index e7e5933443e..ba25f60cc1e 100644 --- a/subsys/net/ip/ipv4_autoconf.c +++ b/subsys/net/ip/ipv4_autoconf.c @@ -138,7 +138,7 @@ enum net_verdict net_ipv4_autoconf_input(struct net_if *iface, break; case NET_IPV4_AUTOCONF_ANNOUNCE: case NET_IPV4_AUTOCONF_ASSIGNED: - if (cfg->ipv4auto.conflict_cnt == 1) { + if (cfg->ipv4auto.conflict_cnt == 1U) { /* defend IP */ ipv4_autoconf_send_announcement(&cfg->ipv4auto); } else { @@ -164,12 +164,12 @@ static void ipv4_autoconf_send(struct net_if_ipv4_autoconf *ipv4auto) { switch (ipv4auto->state) { case NET_IPV4_AUTOCONF_INIT: - ipv4auto->probe_cnt = 0; - ipv4auto->announce_cnt = 0; - ipv4auto->conflict_cnt = 0; + ipv4auto->probe_cnt = 0U; + ipv4auto->announce_cnt = 0U; + ipv4auto->conflict_cnt = 0U; (void)memset(&ipv4auto->current_ip, 0, sizeof(struct in_addr)); - ipv4auto->requested_ip.s4_addr[0] = 169; - ipv4auto->requested_ip.s4_addr[1] = 254; + ipv4auto->requested_ip.s4_addr[0] = 169U; + ipv4auto->requested_ip.s4_addr[1] = 254U; ipv4auto->requested_ip.s4_addr[2] = sys_rand32_get() % 254; ipv4auto->requested_ip.s4_addr[3] = sys_rand32_get() % 254; @@ -179,9 +179,9 @@ static void ipv4_autoconf_send(struct net_if_ipv4_autoconf *ipv4auto) ipv4_autoconf_send_probe(ipv4auto); break; case NET_IPV4_AUTOCONF_RENEW: - ipv4auto->probe_cnt = 0; - ipv4auto->announce_cnt = 0; - ipv4auto->conflict_cnt = 0; + ipv4auto->probe_cnt = 0U; + ipv4auto->announce_cnt = 0U; + ipv4auto->conflict_cnt = 0U; (void)memset(&ipv4auto->current_ip, 0, sizeof(struct in_addr)); NET_DBG("%s: Starting probe for 169.254.%d.%d", "Renew", ipv4auto->requested_ip.s4_addr[2], diff --git a/subsys/net/ip/ipv6.c b/subsys/net/ip/ipv6.c index d2dca1e8428..0d4214614dc 100644 --- a/subsys/net/ip/ipv6.c +++ b/subsys/net/ip/ipv6.c @@ -69,14 +69,14 @@ int net_ipv6_create(struct net_pkt *pkt, } ipv6_hdr->vtc = 0x60; - ipv6_hdr->tcflow = 0; - ipv6_hdr->flow = 0; - ipv6_hdr->len = 0; - ipv6_hdr->nexthdr = 0; + ipv6_hdr->tcflow = 0U; + ipv6_hdr->flow = 0U; + ipv6_hdr->len = 0U; + ipv6_hdr->nexthdr = 0U; /* User can tweak the default hop limit if needed */ ipv6_hdr->hop_limit = net_pkt_ipv6_hop_limit(pkt); - if (ipv6_hdr->hop_limit == 0) { + if (ipv6_hdr->hop_limit == 0U) { ipv6_hdr->hop_limit = net_if_ipv6_get_hop_limit(net_pkt_iface(pkt)); } @@ -105,7 +105,7 @@ int net_ipv6_finalize(struct net_pkt *pkt, u8_t next_header_proto) ipv6_hdr->len = htons(net_pkt_get_len(pkt) - sizeof(struct net_ipv6_hdr)); - if (net_pkt_ipv6_next_hdr(pkt) != 255) { + if (net_pkt_ipv6_next_hdr(pkt) != 255U) { ipv6_hdr->nexthdr = net_pkt_ipv6_next_hdr(pkt); } else { ipv6_hdr->nexthdr = next_header_proto; @@ -113,7 +113,7 @@ int net_ipv6_finalize(struct net_pkt *pkt, u8_t next_header_proto) net_pkt_set_data(pkt, &ipv6_access); - if (net_pkt_ipv6_next_hdr(pkt) != 255 && + if (net_pkt_ipv6_next_hdr(pkt) != 255U && net_pkt_skip(pkt, net_pkt_ipv6_ext_len(pkt))) { return -ENOBUFS; } @@ -185,14 +185,14 @@ static inline int ipv6_handle_ext_hdr_options(struct net_pkt *pkt, return -ENOBUFS; } - exthdr_len = exthdr_len * 8 + 8; + exthdr_len = exthdr_len * 8U + 8; if (exthdr_len > pkt_len) { NET_DBG("Corrupted packet, extension header %d too long " "(max %d bytes)", exthdr_len, pkt_len); return -EINVAL; } - length += 2; + length += 2U; while (length < exthdr_len) { u8_t opt_type, opt_len; diff --git a/subsys/net/ip/ipv6_fragment.c b/subsys/net/ip/ipv6_fragment.c index 6765f18b811..69347df0656 100644 --- a/subsys/net/ip/ipv6_fragment.c +++ b/subsys/net/ip/ipv6_fragment.c @@ -88,7 +88,7 @@ int net_ipv6_find_last_ext_hdr(struct net_pkt *pkt, u16_t *next_hdr_off, goto fail; } - length = length * 8 + 8 - 2; + length = length * 8U + 8 - 2; if (net_pkt_skip(pkt, length)) { goto fail; @@ -381,7 +381,7 @@ static bool fragment_verify(struct net_ipv6_reassembly *reass) NET_DBG("pkt %p offset %u", reass->pkt[0], offset); - if (offset != 0) { + if (offset != 0U) { return false; } @@ -610,9 +610,9 @@ static int send_ipv6_fragment(struct net_pkt *pkt, } frag_hdr->nexthdr = next_hdr; - frag_hdr->reserved = 0; + frag_hdr->reserved = 0U; frag_hdr->id = net_pkt_ipv6_fragment_id(pkt); - frag_hdr->offset = htons(((frag_offset / 8) << 3) | !final); + frag_hdr->offset = htons(((frag_offset / 8U) << 3) | !final); if (net_pkt_set_data(frag_pkt, &frag_access)) { goto fail; diff --git a/subsys/net/ip/ipv6_mld.c b/subsys/net/ip/ipv6_mld.c index efe076bef18..73ee7eb7612 100644 --- a/subsys/net/ip/ipv6_mld.c +++ b/subsys/net/ip/ipv6_mld.c @@ -52,7 +52,7 @@ static int mld_create(struct net_pkt *pkt, } mld->record_type = record_type; - mld->aux_data_len = 0; + mld->aux_data_len = 0U; mld->num_sources = htons(num_sources); net_ipaddr_copy(&mld->mcast_address, addr); @@ -317,7 +317,7 @@ static enum net_verdict handle_mld_query(struct net_pkt *pkt, sizeof(struct in6_addr) * mld_query->num_sources; if (length < pkt_len || pkt_len > NET_IPV6_MTU || - ip_hdr->hop_limit != 1 || icmp_hdr->code != 0) { + ip_hdr->hop_limit != 1U || icmp_hdr->code != 0U) { goto drop; } diff --git a/subsys/net/ip/ipv6_nbr.c b/subsys/net/ip/ipv6_nbr.c index 7364e5d4f11..1926a393296 100644 --- a/subsys/net/ip/ipv6_nbr.c +++ b/subsys/net/ip/ipv6_nbr.c @@ -164,7 +164,7 @@ static void ipv6_nbr_set_state(struct net_nbr *nbr, k_sem_take(&nbr_lock, K_FOREVER); - stale_counter = 0; + stale_counter = 0U; for (i = 0; i < CONFIG_NET_IPV6_MAX_NEIGHBORS; i++) { n = get_nbr(i); @@ -781,7 +781,7 @@ enum net_verdict net_ipv6_prepare_for_send(struct net_pkt *pkt) /* If we have already fragmented the packet, the fragment id will * contain a proper value and we can skip other checks. */ - if (net_pkt_ipv6_fragment_id(pkt) == 0) { + if (net_pkt_ipv6_fragment_id(pkt) == 0U) { u16_t mtu = net_if_get_mtu(net_pkt_iface(pkt)); size_t pkt_len = net_pkt_get_len(pkt); @@ -972,9 +972,9 @@ struct net_nbr *net_ipv6_get_nbr(struct net_if *iface, u8_t idx) static inline u8_t get_llao_len(struct net_if *iface) { - if (net_if_get_link_addr(iface)->len == 6) { + if (net_if_get_link_addr(iface)->len == 6U) { return 8; - } else if (net_if_get_link_addr(iface)->len == 8) { + } else if (net_if_get_link_addr(iface)->len == 8U) { return 16; } @@ -1159,7 +1159,7 @@ static enum net_verdict handle_ns_input(struct net_pkt *pkt, sizeof(struct net_icmp_hdr) + sizeof(struct net_icmpv6_ns_hdr))) || (ip_hdr->hop_limit != NET_IPV6_ND_HOP_LIMIT)) && - (net_ipv6_is_addr_mcast(&ns_hdr->tgt) && icmp_hdr->code != 0)) { + (net_ipv6_is_addr_mcast(&ns_hdr->tgt) && icmp_hdr->code != 0U)) { goto drop; } @@ -1714,7 +1714,7 @@ static enum net_verdict handle_na_input(struct net_pkt *pkt, net_ipv6_is_addr_mcast(&na_hdr->tgt) || (na_hdr->flags & NET_ICMPV6_NA_FLAG_SOLICITED && net_ipv6_is_addr_mcast(&ip_hdr->dst))) && - (icmp_hdr->code != 0)) { + (icmp_hdr->code != 0U)) { goto drop; } @@ -1816,7 +1816,7 @@ int net_ipv6_send_ns(struct net_if *iface, if (is_my_address) { src = net_ipv6_unspecified_address(); - llao_len = 0; + llao_len = 0U; } else { if (!src) { src = net_if_ipv6_select_src_addr(iface, dst); @@ -1852,7 +1852,7 @@ int net_ipv6_send_ns(struct net_if *iface, goto drop; } - ns_hdr->reserved = 0; + ns_hdr->reserved = 0U; net_ipaddr_copy(&ns_hdr->tgt, tgt); if (net_pkt_set_data(pkt, &ns_access)) { @@ -2015,7 +2015,7 @@ static inline struct net_nbr *handle_ra_neighbor(struct net_pkt *pkt, u8_t len) return NULL; } - padding = len * 8 - 2 - lladdr.len; + padding = len * 8U - 2 - lladdr.len; if (padding) { if (net_pkt_skip(pkt, padding)) { return NULL; @@ -2228,12 +2228,12 @@ static inline bool handle_ra_6co(struct net_pkt *pkt, u8_t len) * bits in the Context Prefix field that are valid. The value ranges * from 0 to 128. If it is more than 64, then the Length MUST be 3. */ - if ((context->context_len > 64 && len != 3) || - (context->context_len <= 64 && len != 2)) { + if ((context->context_len > 64 && len != 3U) || + (context->context_len <= 64U && len != 2U)) { return false; } - context->context_len = context->context_len / 8; + context->context_len = context->context_len / 8U; /* context_len: The number of leading bits in the Context Prefix * field that are valid. Rest must be set to 0 by the sender and @@ -2280,7 +2280,8 @@ static enum net_verdict handle_ra_input(struct net_pkt *pkt, sizeof(struct net_icmpv6_ra_hdr) + sizeof(struct net_icmpv6_nd_opt_hdr))) || (ip_hdr->hop_limit != NET_IPV6_ND_HOP_LIMIT) || - !net_ipv6_is_ll_addr(&ip_hdr->src)) && icmp_hdr->code != 0) { + !net_ipv6_is_ll_addr(&ip_hdr->src)) && + icmp_hdr->code != 0U) { goto drop; } @@ -2354,7 +2355,7 @@ static enum net_verdict handle_ra_input(struct net_pkt *pkt, #if defined(CONFIG_NET_6LO_CONTEXT) case NET_ICMPV6_ND_OPT_6CO: /* RFC 6775, 4.2 (Length)*/ - if (!(nd_opt_hdr->len == 2 || nd_opt_hdr->len == 3)) { + if (!(nd_opt_hdr->len == 2U || nd_opt_hdr->len == 3U)) { NET_ERR("DROP: Invalid 6CO length %d", nd_opt_hdr->len); goto drop; @@ -2383,7 +2384,7 @@ static enum net_verdict handle_ra_input(struct net_pkt *pkt, default: NET_DBG("Unknown ND option 0x%x", nd_opt_hdr->type); skip: - if (net_pkt_skip(pkt, nd_opt_hdr->len * 8 - 2)) { + if (net_pkt_skip(pkt, nd_opt_hdr->len * 8U - 2)) { goto drop; } diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index 6ebe2786831..069c6d47164 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -100,7 +100,7 @@ static u16_t find_available_port(struct net_context *context, do { local_port = sys_rand32_get() | 0x8000; - if (local_port <= 1023) { + if (local_port <= 1023U) { /* 0 - 1023 ports are reserved */ continue; } @@ -242,7 +242,7 @@ int net_context_get(sa_family_t family, } contexts[i].iface = -1; - contexts[i].flags = 0; + contexts[i].flags = 0U; atomic_set(&contexts[i].refcount, 1); net_context_set_family(&contexts[i], family); @@ -1162,7 +1162,7 @@ static int context_setup_udp_packet(struct net_context *context, socklen_t addrlen) { int ret = -EINVAL; - u16_t dst_port = 0; + u16_t dst_port = 0U; if (IS_ENABLED(CONFIG_NET_IPV4) && net_context_get_family(context) == AF_INET) { diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 6810eacd732..b1584f14584 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -388,7 +388,7 @@ static u8_t get_ipaddr_diff(const u8_t *src, const u8_t *dst, int addr_len) for (j = 0U; j < addr_len; j++) { if (src[j] == dst[j]) { - len += 8; + len += 8U; } else { xor = src[j] ^ dst[j]; for (k = 0U; k < 8; k++) { @@ -562,7 +562,7 @@ static void net_if_ipv6_start_dad(struct net_if *iface, log_strdup(net_sprint_ipv6_addr( &ifaddr->address.in6_addr))); - ifaddr->dad_count = 1; + ifaddr->dad_count = 1U; if (!net_ipv6_start_dad(iface, ifaddr)) { k_delayed_work_submit(&ifaddr->dad_timer, DAD_TIMEOUT); diff --git a/subsys/net/ip/net_pkt.c b/subsys/net/ip/net_pkt.c index 235c83e3bc2..cce94453bfd 100644 --- a/subsys/net/ip/net_pkt.c +++ b/subsys/net/ip/net_pkt.c @@ -386,7 +386,7 @@ struct net_buf *net_pkt_get_reserve_data(struct net_buf_pool *pool, } #if NET_LOG_LEVEL >= LOG_LEVEL_DBG - NET_FRAG_CHECK_IF_NOT_IN_USE(frag, frag->ref + 1); + NET_FRAG_CHECK_IF_NOT_IN_USE(frag, frag->ref + 1U); #endif net_pkt_alloc_add(frag, false, caller, line); @@ -550,7 +550,7 @@ void net_pkt_unref(struct net_pkt *pkt) pool2str(net_buf_pool_get(frag->pool_id)), get_name(net_buf_pool_get(frag->pool_id)), get_frees(net_buf_pool_get(frag->pool_id)), frag, - frag->ref - 1, frag->frags, caller, line); + frag->ref - 1U, frag->frags, caller, line); #endif if (!frag->ref) { @@ -644,7 +644,7 @@ struct net_buf *net_pkt_frag_ref(struct net_buf *frag) pool2str(net_buf_pool_get(frag->pool_id)), get_name(net_buf_pool_get(frag->pool_id)), get_frees(net_buf_pool_get(frag->pool_id)), - frag, frag->ref + 1, caller, line); + frag, frag->ref + 1U, caller, line); #endif return net_buf_ref(frag); @@ -670,10 +670,10 @@ void net_pkt_frag_unref(struct net_buf *frag) pool2str(net_buf_pool_get(frag->pool_id)), get_name(net_buf_pool_get(frag->pool_id)), get_frees(net_buf_pool_get(frag->pool_id)), - frag, frag->ref - 1, caller, line); + frag, frag->ref - 1U, caller, line); #endif - if (frag->ref == 1) { + if (frag->ref == 1U) { net_pkt_alloc_del(frag, caller, line); } @@ -699,7 +699,7 @@ struct net_buf *net_pkt_frag_del(struct net_pkt *pkt, if (pkt->frags == frag && !parent) { struct net_buf *tmp; - if (frag->ref == 1) { + if (frag->ref == 1U) { net_pkt_alloc_del(frag, caller, line); } @@ -709,7 +709,7 @@ struct net_buf *net_pkt_frag_del(struct net_pkt *pkt, return tmp; } - if (frag->ref == 1) { + if (frag->ref == 1U) { net_pkt_alloc_del(frag, caller, line); } @@ -1807,7 +1807,7 @@ u16_t net_pkt_get_current_offset(struct net_pkt *pkt) return 0; } - offset = 0; + offset = 0U; while (buf != pkt->cursor.buf) { offset += buf->len; diff --git a/subsys/net/ip/net_shell.c b/subsys/net/ip/net_shell.c index 6196f29af0f..0c3fc575265 100644 --- a/subsys/net/ip/net_shell.c +++ b/subsys/net/ip/net_shell.c @@ -2256,7 +2256,7 @@ static void address_lifetime_cb(struct net_if *iface, void *user_data) "infinite"); } else { snprintk(remaining_str, sizeof(remaining_str) - 1, - "%u", (u32_t)(remaining / 1000)); + "%u", (u32_t)(remaining / 1000U)); } PR("%s \t%s\t%s \t%s/%d\n", @@ -2602,7 +2602,7 @@ static void nbr_cb(struct net_nbr *nbr, void *user_data) net_sprint_ll_addr( net_nbr_get_lladdr(nbr->idx)->addr, net_nbr_get_lladdr(nbr->idx)->len), - net_nbr_get_lladdr(nbr->idx)->len == 8 ? "" : padding, + net_nbr_get_lladdr(nbr->idx)->len == 8U ? "" : padding, net_sprint_ipv6_addr(&net_ipv6_nbr_data(nbr)->addr)); } #endif @@ -3069,7 +3069,7 @@ static void get_my_ipv6_addr(struct net_if *iface, memcpy(&net_sin6(myaddr)->sin6_addr, my6addr, sizeof(struct in6_addr)); - net_sin6(myaddr)->sin6_port = 0; /* let the IP stack to select */ + net_sin6(myaddr)->sin6_port = 0U; /* let the IP stack to select */ #endif } @@ -3082,7 +3082,7 @@ static void get_my_ipv4_addr(struct net_if *iface, &iface->config.ip.ipv4->unicast[0].address.in_addr, sizeof(struct in_addr)); - net_sin(myaddr)->sin_port = 0; /* let the IP stack to select */ + net_sin(myaddr)->sin_port = 0U; /* let the IP stack to select */ #endif } diff --git a/subsys/net/ip/route.c b/subsys/net/ip/route.c index 93dedd986b7..4b2901b1fd6 100644 --- a/subsys/net/ip/route.c +++ b/subsys/net/ip/route.c @@ -548,7 +548,7 @@ int net_route_del_by_nexthop_data(struct net_if *iface, continue; } - if (nbr->extra_data_size == 0) { + if (nbr->extra_data_size == 0U) { continue; } diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index 49b44dd4c79..0d2147d455f 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -471,9 +471,9 @@ static int prepare_segment(struct net_tcp *tcp, tcp_hdr->offset = (NET_TCPH_LEN + optlen) << 2; tcp_hdr->flags = segment->flags; sys_put_be16(segment->wnd, tcp_hdr->wnd); - tcp_hdr->chksum = 0; - tcp_hdr->urg[0] = 0; - tcp_hdr->urg[1] = 0; + tcp_hdr->chksum = 0U; + tcp_hdr->urg[0] = 0U; + tcp_hdr->urg[1] = 0U; net_pkt_set_data(pkt, &tcp_access); @@ -888,7 +888,7 @@ int net_tcp_send_pkt(struct net_pkt *pkt) if (sys_get_be32(tcp_hdr->ack) != ctx->tcp->send_ack) { sys_put_be32(ctx->tcp->send_ack, tcp_hdr->ack); - tcp_hdr->chksum = 0; + tcp_hdr->chksum = 0U; calc_chksum = true; } @@ -898,9 +898,9 @@ int net_tcp_send_pkt(struct net_pkt *pkt) * anyway if we know we need it just to sanify edge cases. */ if (ctx->tcp->sent_ack != ctx->tcp->send_ack && - (tcp_hdr->flags & NET_TCP_ACK) == 0) { + (tcp_hdr->flags & NET_TCP_ACK) == 0U) { tcp_hdr->flags |= NET_TCP_ACK; - tcp_hdr->chksum = 0; + tcp_hdr->chksum = 0U; calc_chksum = true; } @@ -920,7 +920,7 @@ int net_tcp_send_pkt(struct net_pkt *pkt) } if (tcp_hdr->flags & NET_TCP_FIN) { - ctx->tcp->fin_sent = 1; + ctx->tcp->fin_sent = 1U; } ctx->tcp->sent_ack = ctx->tcp->send_ack; @@ -1099,10 +1099,10 @@ bool net_tcp_ack_received(struct net_context *ctx, u32_t ack) * as one sequence number. */ if (tcp_hdr->flags & NET_TCP_SYN) { - seq_len += 1; + seq_len += 1U; } if (tcp_hdr->flags & NET_TCP_FIN) { - seq_len += 1; + seq_len += 1U; } /* Last sequence number in this packet. */ @@ -1280,7 +1280,7 @@ int net_tcp_finalize(struct net_pkt *pkt) return -ENOBUFS; } - tcp_hdr->chksum = 0; + tcp_hdr->chksum = 0U; if (net_if_need_calc_tx_checksum(net_pkt_iface(pkt))) { tcp_hdr->chksum = net_calc_chksum_tcp(pkt); @@ -1328,14 +1328,14 @@ int net_tcp_parse_opts(struct net_pkt *pkt, int opt_totlen, /* Subtract opt/optlen size now to avoid doing this * repeatedly. */ - optlen -= 2; + optlen -= 2U; if (opt_totlen < optlen) { goto error; } switch (opt) { case NET_TCP_MSS_OPT: - if (optlen != 2) { + if (optlen != 2U) { goto error; } @@ -1770,7 +1770,7 @@ static void print_send_info(struct net_pkt *pkt, const char *msg, const struct sockaddr *remote) { if (CONFIG_NET_TCP_LOG_LEVEL >= LOG_LEVEL_DBG) { - u16_t port = 0; + u16_t port = 0U; if (IS_ENABLED(CONFIG_NET_IPV4) && net_pkt_family(pkt) == AF_INET) { @@ -2022,7 +2022,7 @@ resend_ack: net_tcp_change_state(context->tcp, NET_TCP_TIME_WAIT); } - context->tcp->fin_rcvd = 1; + context->tcp->fin_rcvd = 1U; } data_len = net_pkt_remaining_data(pkt); @@ -2035,7 +2035,7 @@ resend_ack: * then net_tcp_get_recv_wnd(context->tcp) can be only 0 * here. */ - if (data_len == 1) { + if (data_len == 1U) { goto resend_ack; } @@ -2052,14 +2052,14 @@ resend_ack: if (data_len > 0) { ret = net_context_packet_received(conn, pkt, ip_hdr, proto_hdr, context->tcp->recv_user_data); - } else if (data_len == 0) { + } else if (data_len == 0U) { net_pkt_unref(pkt); } /* Increment the ack */ context->tcp->send_ack += data_len; if (tcp_flags & NET_TCP_FIN) { - context->tcp->send_ack += 1; + context->tcp->send_ack += 1U; } send_ack(context, &conn->remote_addr, false); @@ -2578,7 +2578,7 @@ struct net_tcp_hdr *net_tcp_input(struct net_pkt *pkt, if (IS_ENABLED(CONFIG_NET_TCP_CHECKSUM) && net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) && - net_calc_chksum_tcp(pkt) != 0) { + net_calc_chksum_tcp(pkt) != 0U) { NET_DBG("DROP: checksum mismatch"); goto drop; } diff --git a/subsys/net/ip/trickle.c b/subsys/net/ip/trickle.c index cf3260fcad9..093878df5a3 100644 --- a/subsys/net/ip/trickle.c +++ b/subsys/net/ip/trickle.c @@ -55,7 +55,7 @@ static void double_interval_timeout(struct k_work *work) u32_t rand_time; u32_t last_end = get_end(trickle); - trickle->c = 0; + trickle->c = 0U; NET_DBG("now %u (was at %u)", k_uptime_get_32(), last_end); @@ -126,7 +126,7 @@ static void setup_new_interval(struct net_trickle *trickle) { u32_t t; - trickle->c = 0; + trickle->c = 0U; t = get_t(trickle->I); @@ -197,7 +197,7 @@ int net_trickle_stop(struct net_trickle *trickle) k_delayed_work_cancel(&trickle->timer); - trickle->I = 0; + trickle->I = 0U; return 0; } diff --git a/subsys/net/ip/udp.c b/subsys/net/ip/udp.c index fd40f0ba7fd..fe70ac1b892 100644 --- a/subsys/net/ip/udp.c +++ b/subsys/net/ip/udp.c @@ -29,8 +29,8 @@ int net_udp_create(struct net_pkt *pkt, u16_t src_port, u16_t dst_port) udp_hdr->src_port = src_port; udp_hdr->dst_port = dst_port; - udp_hdr->len = 0; - udp_hdr->chksum = 0; + udp_hdr->len = 0U; + udp_hdr->chksum = 0U; return net_pkt_set_data(pkt, &udp_access); } @@ -150,7 +150,7 @@ struct net_udp_hdr *net_udp_input(struct net_pkt *pkt, if (IS_ENABLED(CONFIG_NET_UDP_CHECKSUM) && net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) && - net_calc_chksum_udp(pkt) != 0) { + net_calc_chksum_udp(pkt) != 0U) { NET_DBG("DROP: checksum mismatch"); goto drop; } diff --git a/subsys/net/ip/utils.c b/subsys/net/ip/utils.c index 7306db338cb..5cfd4f10664 100644 --- a/subsys/net/ip/utils.c +++ b/subsys/net/ip/utils.c @@ -101,7 +101,7 @@ char *net_sprint_ll_addr_buf(const u8_t *ll, u8_t ll_len, for (i = 0U, blen = buflen; i < len && blen > 0; i++) { ptr = net_byte_to_hex(ptr, (char)ll[i], 'A', true); *ptr++ = ':'; - blen -= 3; + blen -= 3U; } if (!(ptr - buf)) { @@ -122,7 +122,7 @@ static int net_value_to_udec(char *buf, u32_t value, int precision) divisor = 1000000000U; if (precision < 0) precision = 1; - for (i = 9; i >= 0; i--, divisor /= 10) { + for (i = 9; i >= 0; i--, divisor /= 10U) { temp = value / divisor; value = value % divisor; if ((precision > i) || (temp != 0)) { @@ -174,7 +174,7 @@ char *net_addr_ntop(sa_family_t family, const void *src, } } - if (longest == 1) { + if (longest == 1U) { pos = -1; } @@ -194,7 +194,7 @@ char *net_addr_ntop(sa_family_t family, const void *src, value = (u32_t)addr->s4_addr[i]; /* net_byte_to_udec() eats 0 */ - if (value == 0) { + if (value == 0U) { *ptr++ = '0'; *ptr++ = delim; continue; @@ -210,13 +210,13 @@ char *net_addr_ntop(sa_family_t family, const void *src, /* IPv6 address */ if (i == pos) { - if (needcolon || i == 0) { + if (needcolon || i == 0U) { *ptr++ = ':'; } *ptr++ = ':'; needcolon = false; - i += longest - 1; + i += longest - 1U; continue; } @@ -504,7 +504,7 @@ u16_t net_calc_chksum(struct net_pkt *pkt, u8_t proto) sum = pkt_calc_chksum(pkt, sum); - sum = (sum == 0) ? 0xffff : htons(sum); + sum = (sum == 0U) ? 0xffff : htons(sum); net_pkt_cursor_restore(pkt, &backup); @@ -520,7 +520,7 @@ u16_t net_calc_chksum_ipv4(struct net_pkt *pkt) sum = calc_chksum(0, pkt->buffer->data, net_pkt_ip_hdr_len(pkt)); - sum = (sum == 0) ? 0xffff : htons(sum); + sum = (sum == 0U) ? 0xffff : htons(sum); return ~sum; } diff --git a/subsys/net/l2/bluetooth/bluetooth.c b/subsys/net/l2/bluetooth/bluetooth.c index 7b4db539664..55d4f64e57c 100644 --- a/subsys/net/l2/bluetooth/bluetooth.c +++ b/subsys/net/l2/bluetooth/bluetooth.c @@ -354,7 +354,7 @@ static bool eir_found(u8_t type, const u8_t *data, u8_t data_len, return false; } - if (data_len % sizeof(u16_t) != 0) { + if (data_len % sizeof(u16_t) != 0U) { NET_ERR("AD malformed\n"); return false; } @@ -397,7 +397,7 @@ static bool ad_parse(struct net_buf_simple *ad, u8_t type; /* Check for early termination */ - if (len == 0) { + if (len == 0U) { return false; } diff --git a/subsys/net/l2/canbus/canbus.c b/subsys/net/l2/canbus/canbus.c index 7531c21e920..4c635661179 100644 --- a/subsys/net/l2/canbus/canbus.c +++ b/subsys/net/l2/canbus/canbus.c @@ -17,10 +17,10 @@ static inline enum net_verdict canbus_recv(struct net_if *iface, struct net_pkt *pkt) { net_pkt_lladdr_src(pkt)->addr = NULL; - net_pkt_lladdr_src(pkt)->len = 0; + net_pkt_lladdr_src(pkt)->len = 0U; net_pkt_lladdr_src(pkt)->type = NET_LINK_CANBUS; net_pkt_lladdr_dst(pkt)->addr = NULL; - net_pkt_lladdr_dst(pkt)->len = 0; + net_pkt_lladdr_dst(pkt)->len = 0U; net_pkt_lladdr_dst(pkt)->type = NET_LINK_CANBUS; net_pkt_set_family(pkt, AF_CAN); diff --git a/subsys/net/l2/dummy/dummy.c b/subsys/net/l2/dummy/dummy.c index 74e4156276a..c56ae473bca 100644 --- a/subsys/net/l2/dummy/dummy.c +++ b/subsys/net/l2/dummy/dummy.c @@ -18,10 +18,10 @@ static inline enum net_verdict dummy_recv(struct net_if *iface, struct net_pkt *pkt) { net_pkt_lladdr_src(pkt)->addr = NULL; - net_pkt_lladdr_src(pkt)->len = 0; + net_pkt_lladdr_src(pkt)->len = 0U; net_pkt_lladdr_src(pkt)->type = NET_LINK_DUMMY; net_pkt_lladdr_dst(pkt)->addr = NULL; - net_pkt_lladdr_dst(pkt)->len = 0; + net_pkt_lladdr_dst(pkt)->len = 0U; net_pkt_lladdr_dst(pkt)->type = NET_LINK_DUMMY; return NET_CONTINUE; diff --git a/subsys/net/l2/ethernet/ethernet.c b/subsys/net/l2/ethernet/ethernet.c index f4b6d0be56a..f660aaecbce 100644 --- a/subsys/net/l2/ethernet/ethernet.c +++ b/subsys/net/l2/ethernet/ethernet.c @@ -262,7 +262,7 @@ static inline bool ethernet_ipv4_dst_is_broadcast_or_mcast(struct net_pkt *pkt) { if (net_ipv4_is_addr_bcast(net_pkt_iface(pkt), &NET_IPV4_HDR(pkt)->dst) || - NET_IPV4_HDR(pkt)->dst.s4_addr[0] == 224) { + NET_IPV4_HDR(pkt)->dst.s4_addr[0] == 224U) { return true; } @@ -273,7 +273,7 @@ static bool ethernet_fill_in_dst_on_ipv4_mcast(struct net_pkt *pkt, struct net_eth_addr *dst) { if (net_pkt_family(pkt) == AF_INET && - NET_IPV4_HDR(pkt)->dst.s4_addr[0] == 224) { + NET_IPV4_HDR(pkt)->dst.s4_addr[0] == 224U) { /* Multicast address */ dst->addr[0] = 0x01; dst->addr[1] = 0x00; diff --git a/subsys/net/l2/ethernet/gptp/gptp.c b/subsys/net/l2/ethernet/gptp/gptp.c index a5e4f86abc4..811922140cd 100644 --- a/subsys/net/l2/ethernet/gptp/gptp.c +++ b/subsys/net/l2/ethernet/gptp/gptp.c @@ -389,7 +389,7 @@ static void gptp_init_clock_ds(void) default_ds->priority2 = GPTP_PRIORITY2_DEFAULT; default_ds->cur_utc_offset = 37U; /* Current leap seconds TAI - UTC */ - default_ds->flags.all = 0; + default_ds->flags.all = 0U; default_ds->flags.octets[1] = GPTP_FLAG_TIME_TRACEABLE; default_ds->time_source = GPTP_TS_INTERNAL_OSCILLATOR; @@ -402,7 +402,7 @@ static void gptp_init_clock_ds(void) memcpy(parent_ds->port_id.clk_id, default_ds->clk_id, GPTP_CLOCK_ID_LEN); memcpy(parent_ds->gm_id, default_ds->clk_id, GPTP_CLOCK_ID_LEN); - parent_ds->port_id.port_number = 0; + parent_ds->port_id.port_number = 0U; /* TODO: Check correct value for below field. */ parent_ds->cumulative_rate_ratio = 0; @@ -597,9 +597,9 @@ void gptp_set_time_itv(struct gptp_uscaled_ns *interval, { int i; - if (seconds == 0) { - interval->low = 0; - interval->high = 0; + if (seconds == 0U) { + interval->low = 0U; + interval->high = 0U; return; } else if (log_msg_interval >= 96) { /* Overflow, set maximum. */ @@ -609,8 +609,8 @@ void gptp_set_time_itv(struct gptp_uscaled_ns *interval, return; } else if (log_msg_interval <= -64) { /* Underflow, set to 0. */ - interval->low = 0; - interval->high = 0; + interval->low = 0U; + interval->high = 0U; return; } @@ -622,7 +622,7 @@ void gptp_set_time_itv(struct gptp_uscaled_ns *interval, if (log_msg_interval <= 0) { interval->low >>= -log_msg_interval; - interval->high = 0; + interval->high = 0U; } else { /* Find highest bit set. */ for (i = 63; i >= 0; i--) { @@ -643,7 +643,7 @@ void gptp_set_time_itv(struct gptp_uscaled_ns *interval, * to the number of bits in the left expression’s type */ if (log_msg_interval == 64) { - interval->low = 0; + interval->low = 0U; } else { interval->low <<= log_msg_interval; } @@ -661,7 +661,7 @@ s32_t gptp_uscaled_ns_to_timer_ms(struct gptp_uscaled_ns *usns) } tmp = (usns->low >> 16) / USEC_PER_SEC; - if (tmp == 0) { + if (tmp == 0U) { /* Timer must be started with a minimum value of 1. */ return 1; } @@ -762,12 +762,12 @@ void gptp_update_sync_interval(int port, s8_t log_val) /* Get the time spent from the start of the timer. */ time_spent = old_itv; if (state_pss_send->half_sync_itv_timer_expired) { - time_spent *= 2; + time_spent *= 2U; } time_spent -= remaining; /* Calculate remaining time and if half timer has expired. */ - if ((time_spent / 2) > new_itv) { + if ((time_spent / 2U) > new_itv) { state_pss_send->sync_itv_timer_expired = true; state_pss_send->half_sync_itv_timer_expired = true; new_itv = 1; diff --git a/subsys/net/l2/ethernet/gptp/gptp_md.c b/subsys/net/l2/ethernet/gptp/gptp_md.c index 6df81538645..d01e12de01f 100644 --- a/subsys/net/l2/ethernet/gptp/gptp_md.c +++ b/subsys/net/l2/ethernet/gptp/gptp_md.c @@ -166,7 +166,7 @@ static void gptp_md_pdelay_reset(int port) port_ds = GPTP_PORT_DS(port); if (state->lost_responses < port_ds->allowed_lost_responses) { - state->lost_responses += 1; + state->lost_responses += 1U; } else { port_ds->is_measuring_delay = false; port_ds->as_capable = false; @@ -191,11 +191,11 @@ static void gptp_md_pdelay_check_multiple_resp(int port) state->rcvd_pdelay_follow_up); state->multiple_resp_count++; } else { - state->multiple_resp_count = 0; + state->multiple_resp_count = 0U; } - if (state->multiple_resp_count >= 3) { - state->multiple_resp_count = 0; + if (state->multiple_resp_count >= 3U) { + state->multiple_resp_count = 0U; k_timer_stop(&state->pdelay_timer); state->pdelay_timer_expired = false; @@ -377,7 +377,7 @@ static void gptp_md_pdelay_compute(int port) (s32_t)port_ds->neighbor_prop_delay); } - state->lost_responses = 0; + state->lost_responses = 0U; port_ds->is_measuring_delay = true; pkt = state->rcvd_pdelay_follow_up_ptr; @@ -440,7 +440,7 @@ static void gptp_md_pdelay_req_timeout(struct k_timer *timer) if (timer == &state->pdelay_timer) { state->pdelay_timer_expired = true; - if (state->rcvd_pdelay_resp == 0) { + if (state->rcvd_pdelay_resp == 0U) { GPTP_STATS_INC(port, pdelay_allowed_lost_resp_exceed_count); } @@ -459,10 +459,10 @@ static void gptp_md_start_pdelay_req(int port) port_ds->neighbor_rate_ratio = 1.0; port_ds->is_measuring_delay = false; port_ds->as_capable = false; - state->lost_responses = 0; - state->rcvd_pdelay_resp = 0; - state->rcvd_pdelay_follow_up = 0; - state->multiple_resp_count = 0; + state->lost_responses = 0U; + state->rcvd_pdelay_resp = 0U; + state->rcvd_pdelay_follow_up = 0U; + state->multiple_resp_count = 0U; } static void gptp_md_follow_up_receipt_timeout(struct k_timer *timer) @@ -492,17 +492,17 @@ static void gptp_md_init_pdelay_req_state_machine(int port) state->neighbor_rate_ratio_valid = false; state->init_pdelay_compute = true; - state->rcvd_pdelay_resp = 0; - state->rcvd_pdelay_follow_up = 0; + state->rcvd_pdelay_resp = 0U; + state->rcvd_pdelay_follow_up = 0U; state->pdelay_timer_expired = false; state->rcvd_pdelay_resp_ptr = NULL; state->rcvd_pdelay_follow_up_ptr = NULL; state->tx_pdelay_req_ptr = NULL; - state->ini_resp_evt_tstamp = 0; - state->ini_resp_ingress_tstamp = 0; - state->lost_responses = 0; + state->ini_resp_evt_tstamp = 0U; + state->ini_resp_ingress_tstamp = 0U; + state->lost_responses = 0U; } static void gptp_md_init_pdelay_resp_state_machine(int port) @@ -529,7 +529,7 @@ static void gptp_md_init_sync_rcv_state_machine(int port) state->rcvd_follow_up_ptr = NULL; state->follow_up_timeout_expired = false; - state->follow_up_receipt_timeout = 0; + state->follow_up_receipt_timeout = 0U; state->state = GPTP_SYNC_RCV_DISCARD; } @@ -648,7 +648,7 @@ static void gptp_md_pdelay_req_state_machine(int port) case GPTP_PDELAY_REQ_WAIT_RESP: if (state->pdelay_timer_expired) { state->state = GPTP_PDELAY_REQ_RESET; - } else if (state->rcvd_pdelay_resp != 0) { + } else if (state->rcvd_pdelay_resp != 0U) { pkt = state->rcvd_pdelay_resp_ptr; if (!gptp_handle_pdelay_resp(port, pkt)) { state->state = GPTP_PDELAY_REQ_WAIT_FOLLOW_UP; @@ -662,7 +662,7 @@ static void gptp_md_pdelay_req_state_machine(int port) case GPTP_PDELAY_REQ_WAIT_FOLLOW_UP: if (state->pdelay_timer_expired) { state->state = GPTP_PDELAY_REQ_RESET; - } else if (state->rcvd_pdelay_follow_up != 0) { + } else if (state->rcvd_pdelay_follow_up != 0U) { pkt = state->rcvd_pdelay_follow_up_ptr; if (!gptp_handle_pdelay_follow_up(port, pkt)) { gptp_md_pdelay_compute(port); @@ -678,8 +678,8 @@ static void gptp_md_pdelay_req_state_machine(int port) if (state->pdelay_timer_expired) { gptp_md_pdelay_check_multiple_resp(port); - state->rcvd_pdelay_resp = 0; - state->rcvd_pdelay_follow_up = 0; + state->rcvd_pdelay_resp = 0U; + state->rcvd_pdelay_follow_up = 0U; } break; diff --git a/subsys/net/l2/ethernet/gptp/gptp_messages.c b/subsys/net/l2/ethernet/gptp/gptp_messages.c index 0b833bdfbb7..1a303e401ec 100644 --- a/subsys/net/l2/ethernet/gptp/gptp_messages.c +++ b/subsys/net/l2/ethernet/gptp/gptp_messages.c @@ -213,7 +213,7 @@ struct net_pkt *gptp_prepare_sync(int port) hdr->message_type = GPTP_SYNC_MESSAGE; hdr->ptp_version = GPTP_VERSION; hdr->sequence_id = htons(port_ds->sync_seq_id); - hdr->domain_number = 0; + hdr->domain_number = 0U; hdr->correction_field = 0; hdr->flags.octets[0] = GPTP_FLAG_TWO_STEP; hdr->flags.octets[1] = GPTP_FLAG_PTP_TIMESCALE; @@ -222,9 +222,9 @@ struct net_pkt *gptp_prepare_sync(int port) hdr->control = GPTP_SYNC_CONTROL_VALUE; /* Clear reserved fields. */ - hdr->reserved0 = 0; - hdr->reserved1 = 0; - hdr->reserved2 = 0; + hdr->reserved0 = 0U; + hdr->reserved1 = 0U; + hdr->reserved2 = 0U; /* PTP configuration. */ (void)memset(&sync->reserved, 0, sizeof(sync->reserved)); @@ -268,19 +268,19 @@ struct net_pkt *gptp_prepare_follow_up(int port, struct net_pkt *sync) hdr->message_type = GPTP_FOLLOWUP_MESSAGE; hdr->ptp_version = GPTP_VERSION; hdr->sequence_id = sync_hdr->sequence_id; - hdr->domain_number = 0; + hdr->domain_number = 0U; /* Store timestamp value in correction field. */ hdr->correction_field = gptp_timestamp_to_nsec(&sync->timestamp); - hdr->flags.octets[0] = 0; + hdr->flags.octets[0] = 0U; hdr->flags.octets[1] = GPTP_FLAG_PTP_TIMESCALE; hdr->message_length = htons(sizeof(struct gptp_hdr) + sizeof(struct gptp_follow_up)); hdr->control = GPTP_FUP_CONTROL_VALUE; /* Clear reserved fields. */ - hdr->reserved0 = 0; - hdr->reserved1 = 0; - hdr->reserved2 = 0; + hdr->reserved0 = 0U; + hdr->reserved1 = 0U; + hdr->reserved2 = 0U; /* PTP configuration will be set by the MDSyncSend state machine. */ @@ -316,9 +316,9 @@ struct net_pkt *gptp_prepare_pdelay_req(int port) hdr->message_type = GPTP_PATH_DELAY_REQ_MESSAGE; hdr->ptp_version = GPTP_VERSION; hdr->sequence_id = htons(port_ds->pdelay_req_seq_id); - hdr->domain_number = 0; + hdr->domain_number = 0U; hdr->correction_field = 0; - hdr->flags.octets[0] = 0; + hdr->flags.octets[0] = 0U; hdr->flags.octets[1] = GPTP_FLAG_PTP_TIMESCALE; hdr->message_length = htons(sizeof(struct gptp_hdr) + @@ -328,9 +328,9 @@ struct net_pkt *gptp_prepare_pdelay_req(int port) hdr->log_msg_interval = port_ds->cur_log_pdelay_req_itv; /* Clear reserved fields. */ - hdr->reserved0 = 0; - hdr->reserved1 = 0; - hdr->reserved2 = 0; + hdr->reserved0 = 0U; + hdr->reserved1 = 0U; + hdr->reserved2 = 0U; memcpy(hdr->port_id.clk_id, port_ds->port_id.clk_id, GPTP_CLOCK_ID_LEN); @@ -388,9 +388,9 @@ struct net_pkt *gptp_prepare_pdelay_resp(int port, hdr->log_msg_interval = GPTP_RESP_LOG_MSG_ITV; /* Clear reserved fields. */ - hdr->reserved0 = 0; - hdr->reserved1 = 0; - hdr->reserved2 = 0; + hdr->reserved0 = 0U; + hdr->reserved1 = 0U; + hdr->reserved2 = 0U; memcpy(hdr->port_id.clk_id, port_ds->port_id.clk_id, GPTP_CLOCK_ID_LEN); @@ -446,13 +446,13 @@ struct net_pkt *gptp_prepare_pdelay_follow_up(int port, hdr->control = GPTP_OTHER_CONTROL_VALUE; hdr->log_msg_interval = GPTP_RESP_LOG_MSG_ITV; - hdr->flags.octets[0] = 0; + hdr->flags.octets[0] = 0U; hdr->flags.octets[1] = GPTP_FLAG_PTP_TIMESCALE; /* Clear reserved fields. */ - hdr->reserved0 = 0; - hdr->reserved1 = 0; - hdr->reserved2 = 0; + hdr->reserved0 = 0U; + hdr->reserved1 = 0U; + hdr->reserved2 = 0U; memcpy(hdr->port_id.clk_id, port_ds->port_id.clk_id, GPTP_CLOCK_ID_LEN); @@ -502,9 +502,9 @@ struct net_pkt *gptp_prepare_announce(int port) hdr->transport_specific = GPTP_TRANSPORT_802_1_AS; hdr->ptp_version = GPTP_VERSION; - hdr->domain_number = 0; + hdr->domain_number = 0U; hdr->correction_field = 0; - hdr->flags.octets[0] = 0; + hdr->flags.octets[0] = 0U; /* Copy leap61, leap59, current UTC offset valid, time traceable and * frequency traceable flags. @@ -520,9 +520,9 @@ struct net_pkt *gptp_prepare_announce(int port) hdr->log_msg_interval = port_ds->cur_log_announce_itv; /* Clear reserved fields. */ - hdr->reserved0 = 0; - hdr->reserved1 = 0; - hdr->reserved2 = 0; + hdr->reserved0 = 0U; + hdr->reserved1 = 0U; + hdr->reserved2 = 0U; ann->cur_utc_offset = global_ds->current_utc_offset; ann->time_source = global_ds->time_source; @@ -605,7 +605,7 @@ void gptp_handle_sync(int port, struct net_pkt *pkt) upstream_sync_itv = NSEC_PER_SEC * GPTP_POW2(hdr->log_msg_interval); /* Convert ns to ms. */ - duration = (upstream_sync_itv / 1000000); + duration = (upstream_sync_itv / 1000000U); /* Start timeout timer. */ k_timer_start(&state->follow_up_discard_timer, duration, 0); diff --git a/subsys/net/l2/ethernet/gptp/gptp_mi.c b/subsys/net/l2/ethernet/gptp/gptp_mi.c index 481d373b14d..1e4b56e3733 100644 --- a/subsys/net/l2/ethernet/gptp/gptp_mi.c +++ b/subsys/net/l2/ethernet/gptp/gptp_mi.c @@ -287,7 +287,7 @@ u64_t gptp_get_current_time_nanosecond(int port) ptp_clock_get(clk, &tm); - if (tm.second == 0 && tm.nanosecond == 0) { + if (tm.second == 0U && tm.nanosecond == 0U) { goto use_uptime; } @@ -855,7 +855,7 @@ static inline void gptp_mi_setup_sync_send_time(void) /* Check for overflow */ if (state->sync_send_time.low < time_helper) { - state->sync_send_time.high += 1; + state->sync_send_time.high += 1U; state->sync_send_time.low = UINT64_MAX - state->sync_send_time.low; } @@ -873,7 +873,7 @@ static void gptp_mi_set_ps_sync_cmss(void) sync_info = &state->pss_snd.sync_info; - state->pss_snd.local_port_number = 0; + state->pss_snd.local_port_number = 0U; current_time = gptp_get_current_master_time_nanosecond(); @@ -891,7 +891,7 @@ static void gptp_mi_set_ps_sync_cmss(void) GPTP_DEFAULT_DS()->clk_id, GPTP_CLOCK_ID_LEN); - sync_info->src_port_id.port_number = 0; + sync_info->src_port_id.port_number = 0U; sync_info->log_msg_interval = CONFIG_NET_GPTP_INIT_LOG_SYNC_ITV; sync_info->upstream_tx_time = global_ds->local_time.low; @@ -980,8 +980,8 @@ static void gptp_compute_gm_rate_ratio(void) memcpy(&local_time_n, &global_ds->local_time, sizeof(struct gptp_uscaled_ns)); - if ((src_time_0.second == 0 && src_time_0.fract_nsecond == 0) - || (local_time_0.high == 0 && local_time_0.low == 0)) { + if ((src_time_0.second == 0U && src_time_0.fract_nsecond == 0U) + || (local_time_0.high == 0U && local_time_0.low == 0U)) { memcpy(&src_time_0, &src_time_n, sizeof(struct net_ptp_extended_time)); @@ -1030,7 +1030,7 @@ static void gptp_compute_gm_rate_ratio(void) if (src_time_n.fract_nsecond >= src_time_0.fract_nsecond) { src_time_n.fract_nsecond -= src_time_0.fract_nsecond; } else { - src_time_n.second -= 1; + src_time_n.second -= 1U; src_time_n.fract_nsecond = (NSEC_PER_SEC * GPTP_POW2_16) - src_time_0.fract_nsecond; } @@ -1041,7 +1041,7 @@ static void gptp_compute_gm_rate_ratio(void) if (local_time_n.low >= local_time_0.low) { local_time_n.low -= local_time_0.low; } else { - local_time_n.high -= 1; + local_time_n.high -= 1U; local_time_n.low = UINT64_MAX - local_time_0.low; } @@ -1091,7 +1091,7 @@ static void gptp_mi_clk_master_sync_rcv_state_machine(void) break; case GPTP_CMS_RCV_SOURCE_TIME: - global_ds->local_time.high = 0; + global_ds->local_time.high = 0U; global_ds->local_time.low = gptp_get_current_master_time_nanosecond(); @@ -1162,7 +1162,7 @@ static bool gptp_mi_qualify_announce(int port, struct net_pkt *announce_msg) } len = ntohs(announce->steps_removed); - if (len >= 255) { + if (len >= 255U) { return false; } @@ -1770,7 +1770,7 @@ static void gptp_updt_roles_tree(void) /* Update gmPresent. */ global_ds->gm_present = - (gm_prio->root_system_id.grand_master_prio1 == 255) ? + (gm_prio->root_system_id.grand_master_prio1 == 255U) ? false : true; /* Assign the port role for port 0. */ diff --git a/subsys/net/l2/ieee802154/ieee802154.c b/subsys/net/l2/ieee802154/ieee802154.c index f4450de7685..f20bdaf11d3 100644 --- a/subsys/net/l2/ieee802154/ieee802154.c +++ b/subsys/net/l2/ieee802154/ieee802154.c @@ -110,7 +110,7 @@ static inline void set_pkt_ll_addr(struct net_linkaddr *addr, bool comp, } } else { /* ToDo: Handle short address (lookup known nbr, ...) */ - addr->len = 0; + addr->len = 0U; addr->addr = NULL; } @@ -250,7 +250,7 @@ static int ieee802154_send(struct net_if *iface, struct net_pkt *pkt) ieee802154_fragment_ctx_init(&f_ctx, pkt, len, true); len = 0; - frame_buf.len = 0; + frame_buf.len = 0U; buf = pkt->buffer; while (buf) { @@ -288,7 +288,7 @@ static int ieee802154_send(struct net_if *iface, struct net_pkt *pkt) len += frame_buf.len; /* Reinitializing frame_buf */ - frame_buf.len = 0; + frame_buf.len = 0U; } net_pkt_unref(pkt); diff --git a/subsys/net/l2/ieee802154/ieee802154_fragment.c b/subsys/net/l2/ieee802154/ieee802154_fragment.c index 542d8c2a132..4bcf014794b 100644 --- a/subsys/net/l2/ieee802154/ieee802154_fragment.c +++ b/subsys/net/l2/ieee802154/ieee802154_fragment.c @@ -198,7 +198,7 @@ void ieee802154_fragment(struct ieee802154_fragment_ctx *ctx, max -= ctx->hdr_diff; } else { /* Adding IPv6 dispatch header */ - max += 1; + max += 1U; } } diff --git a/subsys/net/l2/ieee802154/ieee802154_fragment.h b/subsys/net/l2/ieee802154/ieee802154_fragment.h index 19f274ccf1c..3606ea147b0 100644 --- a/subsys/net/l2/ieee802154/ieee802154_fragment.h +++ b/subsys/net/l2/ieee802154/ieee802154_fragment.h @@ -45,8 +45,8 @@ void ieee802154_fragment_ctx_init(struct ieee802154_fragment_ctx *ctx, ctx->pos = ctx->buf->data; ctx->hdr_diff = hdr_diff; ctx->pkt_size = net_pkt_get_len(pkt) + (iphc ? hdr_diff : -1); - ctx->offset = 0; - ctx->processed = 0; + ctx->offset = 0U; + ctx->processed = 0U; } /** diff --git a/subsys/net/l2/ieee802154/ieee802154_frame.c b/subsys/net/l2/ieee802154/ieee802154_frame.c index 4a49be01bab..b320a6d141c 100644 --- a/subsys/net/l2/ieee802154/ieee802154_frame.c +++ b/subsys/net/l2/ieee802154/ieee802154_frame.c @@ -346,7 +346,7 @@ validate_payload_and_mfr(struct ieee802154_mpdu *mpdu, } } else if (type == IEEE802154_FRAME_TYPE_DATA) { /** A data frame embeds a payload */ - if (payload_length == 0) { + if (payload_length == 0U) { return false; } @@ -695,7 +695,7 @@ bool ieee802154_create_data_frame(struct ieee802154_context *ctx, level = ctx->sec_ctx.level; if (level >= IEEE802154_SECURITY_LEVEL_ENC) { - level -= 4; + level -= 4U; } /* p_buf should point to the right place */ @@ -794,13 +794,13 @@ static inline u8_t mac_command_length(enum ieee802154_cfi cfi) case IEEE802154_CFI_ASSOCIATION_REQUEST: case IEEE802154_CFI_DISASSOCIATION_NOTIFICATION: case IEEE802154_CFI_GTS_REQUEST: - length += 1; + length += 1U; break; case IEEE802154_CFI_ASSOCIATION_RESPONSE: - length += 3; + length += 3U; break; case IEEE802154_CFI_COORDINATOR_REALIGNEMENT: - length += 8; + length += 8U; break; default: break; @@ -927,7 +927,7 @@ bool ieee802154_decipher_data_frame(struct net_if *iface, struct net_pkt *pkt, level = ctx->sec_ctx.level; if (level >= IEEE802154_SECURITY_LEVEL_ENC) { - level -= 4; + level -= 4U; } /* We remove tag size from buf's length, it is now useless */ diff --git a/subsys/net/l2/ieee802154/ieee802154_mgmt.c b/subsys/net/l2/ieee802154/ieee802154_mgmt.c index f995514e3ea..61c45f2eab4 100644 --- a/subsys/net/l2/ieee802154/ieee802154_mgmt.c +++ b/subsys/net/l2/ieee802154/ieee802154_mgmt.c @@ -127,7 +127,7 @@ static int ieee802154_scan(u32_t mgmt_request, struct net_if *iface, /* ToDo: For now, we assume we are on 2.4Ghz * (device will have to export capabilities) */ - for (channel = 11U; channel <= 26; channel++) { + for (channel = 11U; channel <= 26U; channel++) { if (IEEE802154_IS_CHAN_UNSCANNED(scan->channel_set, channel)) { continue; } diff --git a/subsys/net/l2/ieee802154/ieee802154_radio_csma_ca.c b/subsys/net/l2/ieee802154/ieee802154_radio_csma_ca.c index e0d418792f0..99917144f15 100644 --- a/subsys/net/l2/ieee802154/ieee802154_radio_csma_ca.c +++ b/subsys/net/l2/ieee802154/ieee802154_radio_csma_ca.c @@ -41,7 +41,7 @@ loop: if (be) { u8_t bo_n = sys_rand32_get() & ((1 << be) - 1); - k_busy_wait(bo_n * 20); + k_busy_wait(bo_n * 20U); } while (1) { diff --git a/subsys/net/l2/ieee802154/ieee802154_radio_utils.h b/subsys/net/l2/ieee802154/ieee802154_radio_utils.h index c316c2d50c8..a9a8f139bf8 100644 --- a/subsys/net/l2/ieee802154/ieee802154_radio_utils.h +++ b/subsys/net/l2/ieee802154/ieee802154_radio_utils.h @@ -59,7 +59,7 @@ static inline int wait_for_ack(struct net_if *iface, k_sem_init(&ctx->ack_lock, 0, UINT_MAX); } - ctx->ack_seq = 0; + ctx->ack_seq = 0U; return ctx->ack_received ? 0 : -EIO; } diff --git a/subsys/net/l2/ieee802154/ieee802154_security.c b/subsys/net/l2/ieee802154/ieee802154_security.c index f27a98a9446..d31d1304f70 100644 --- a/subsys/net/l2/ieee802154/ieee802154_security.c +++ b/subsys/net/l2/ieee802154/ieee802154_security.c @@ -187,8 +187,8 @@ int ieee802154_security_init(struct ieee802154_security_ctx *sec_ctx) sec_ctx->enc.flags = cipher_query_hwcaps(dev); sec_ctx->dec.flags = cipher_query_hwcaps(dev); - sec_ctx->enc.mode_params.ccm_info.nonce_len = 13; - sec_ctx->dec.mode_params.ccm_info.nonce_len = 13; + sec_ctx->enc.mode_params.ccm_info.nonce_len = 13U; + sec_ctx->dec.mode_params.ccm_info.nonce_len = 13U; sec_ctx->enc.device = dev; sec_ctx->dec.device = dev; diff --git a/subsys/net/l2/openthread/openthread_utils.c b/subsys/net/l2/openthread/openthread_utils.c index 6d871a2576f..c89c6439675 100644 --- a/subsys/net/l2/openthread/openthread_utils.c +++ b/subsys/net/l2/openthread/openthread_utils.c @@ -49,7 +49,7 @@ int pkt_list_add(struct openthread_context *context, struct net_pkt *pkt) } if (i_idx == context->pkt_list_out_idx) { - context->pkt_list_full = 1; + context->pkt_list_full = 1U; } context->pkt_list[context->pkt_list_in_idx].pkt = pkt; @@ -78,10 +78,10 @@ void pkt_list_remove_last(struct openthread_context *context) context->pkt_list_out_idx++; if (context->pkt_list_out_idx == CONFIG_OPENTHREAD_PKT_LIST_SIZE) { - context->pkt_list_out_idx = 0; + context->pkt_list_out_idx = 0U; } - context->pkt_list_full = 0; + context->pkt_list_full = 0U; } void add_ipv6_addr_to_zephyr(struct openthread_context *context) diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index d147d5e0c46..7dc79f0bcc5 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -33,10 +33,10 @@ static int wifi_connect(u32_t mgmt_request, struct net_if *iface, if ((params->security > WIFI_SECURITY_TYPE_PSK) || (params->ssid_length > WIFI_SSID_MAX_LEN) || - (params->ssid_length == 0) || + (params->ssid_length == 0U) || ((params->security == WIFI_SECURITY_TYPE_PSK) && ((params->psk_length < 8) || (params->psk_length > 64) || - (params->psk_length == 0) || !params->psk)) || + (params->psk_length == 0U) || !params->psk)) || ((params->channel != WIFI_CHANNEL_ANY) && (params->channel > WIFI_CHANNEL_MAX)) || !params->ssid) { diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index b30a356dba9..43afc19829f 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -64,7 +64,7 @@ static void handle_wifi_scan_result(struct net_mgmt_event_callback *cb) scan_result++; - if (scan_result == 1) { + if (scan_result == 1U) { print(context.shell, SHELL_NORMAL, "%-4s | %-32s %-5s | %-4s | %-4s | %-5s\n", "Num", "SSID", "(len)", "Chan", "RSSI", "Sec"); @@ -161,7 +161,7 @@ static int __wifi_args_to_params(size_t argc, char *argv[], /* SSID length */ params->ssid_length = strtol(argv[1], &endptr, 10); - if (*endptr != '\0' || params->ssid_length <= 2) { + if (*endptr != '\0' || params->ssid_length <= 2U) { return -EINVAL; } @@ -172,7 +172,7 @@ static int __wifi_args_to_params(size_t argc, char *argv[], return -EINVAL; } - if (params->channel == 0) { + if (params->channel == 0U) { params->channel = WIFI_CHANNEL_ANY; } diff --git a/subsys/net/lib/coap/coap.c b/subsys/net/lib/coap/coap.c index 4c985509050..74004aa436d 100644 --- a/subsys/net/lib/coap/coap.c +++ b/subsys/net/lib/coap/coap.c @@ -106,9 +106,9 @@ int coap_packet_init(struct coap_packet *cpkt, u8_t *data, memset(cpkt, 0, sizeof(*cpkt)); cpkt->data = data; - cpkt->offset = 0; + cpkt->offset = 0U; cpkt->max_len = max_len; - cpkt->delta = 0; + cpkt->delta = 0U; hdr = (ver & 0x3) << 6; hdr |= (type & 0x3) << 4; @@ -195,24 +195,24 @@ static int encode_option(struct coap_packet *cpkt, u16_t code, return -EINVAL; } - if (delta_size == 1) { + if (delta_size == 1U) { res = append_u8(cpkt, (u8_t)delta_ext); if (!res) { return -EINVAL; } - } else if (delta_size == 2) { + } else if (delta_size == 2U) { res = append_be16(cpkt, delta_ext); if (!res) { return -EINVAL; } } - if (len_size == 1) { + if (len_size == 1U) { res = append_u8(cpkt, (u8_t)len_ext); if (!res) { return -EINVAL; } - } else if (delta_size == 2) { + } else if (delta_size == 2U) { res = append_be16(cpkt, len_ext); if (!res) { return -EINVAL; @@ -271,7 +271,7 @@ int coap_append_option_int(struct coap_packet *cpkt, u16_t code, { u8_t data[4], len; - if (val == 0) { + if (val == 0U) { data[0] = 0U; len = 0U; } else if (val < 0xFF) { @@ -437,7 +437,7 @@ static int parse_option(u8_t *data, u16_t offset, u16_t *pos, return r; } - *opt_len += 1; + *opt_len += 1U; /* This indicates that options have ended */ if (opt == COAP_MARKER) { @@ -482,7 +482,7 @@ static int parse_option(u8_t *data, u16_t offset, u16_t *pos, *opt_len += len; if (r == 0) { - if (len == 0) { + if (len == 0U) { return r; } @@ -544,11 +544,11 @@ int coap_packet_parse(struct coap_packet *cpkt, u8_t *data, u16_t len, } cpkt->data = data; - cpkt->offset = 0; + cpkt->offset = 0U; cpkt->max_len = len; - cpkt->opt_len = 0; - cpkt->hdr_len = 0; - cpkt->delta = 0; + cpkt->opt_len = 0U; + cpkt->hdr_len = 0U; + cpkt->delta = 0U; /* Token lenghts 9-15 are reserved. */ tkl = cpkt->data[0] & 0x0f; @@ -1104,7 +1104,7 @@ static inline bool is_addr_unspecified(const struct sockaddr *addr) return net_ipv6_is_addr_unspecified( &(net_sin6(addr)->sin6_addr)); } else if (addr->sa_family == AF_INET) { - return net_sin(addr)->sin_addr.s4_addr32[0] == 0; + return net_sin(addr)->sin_addr.s4_addr32[0] == 0U; } return false; @@ -1232,12 +1232,12 @@ struct coap_reply *coap_response_received( for (i = 0, r = replies; i < len; i++, r++) { int age; - if ((r->id == 0) && (r->tkl == 0)) { + if ((r->id == 0U) && (r->tkl == 0U)) { continue; } /* Piggybacked must match id when token is empty */ - if ((r->id != id) && (tkl == 0)) { + if ((r->id != id) && (tkl == 0U)) { continue; } diff --git a/subsys/net/lib/coap/coap_link_format.c b/subsys/net/lib/coap/coap_link_format.c index 219c07ad1bd..a3777f0e1e0 100644 --- a/subsys/net/lib/coap/coap_link_format.c +++ b/subsys/net/lib/coap/coap_link_format.c @@ -78,7 +78,7 @@ static bool match_path_uri(const char * const *path, return false; } - if (len <= 1 || uri[0] != '/') { + if (len <= 1U || uri[0] != '/') { return false; } diff --git a/subsys/net/lib/dns/dns_pack.c b/subsys/net/lib/dns/dns_pack.c index 4363b981d9b..f4c89631862 100644 --- a/subsys/net/lib/dns/dns_pack.c +++ b/subsys/net/lib/dns/dns_pack.c @@ -31,7 +31,7 @@ int dns_msg_pack_qname(u16_t *len, u8_t *buf, u16_t size, lb_size = 0U; dn_size = dns_strlen(domain_name); - if (dn_size == 0) { + if (dn_size == 0U) { return -EINVAL; } @@ -44,7 +44,7 @@ int dns_msg_pack_qname(u16_t *len, u8_t *buf, u16_t size, switch (domain_name[i]) { default: buf[lb_index] = domain_name[i]; - lb_size += 1; + lb_size += 1U; break; case '.': buf[lb_start] = lb_size; @@ -56,7 +56,7 @@ int dns_msg_pack_qname(u16_t *len, u8_t *buf, u16_t size, buf[lb_index] = 0U; break; } - lb_index += 1; + lb_index += 1U; } *len = lb_index; @@ -371,7 +371,7 @@ int dns_copy_qname(u8_t *buf, u16_t *len, u16_t size, /* The domain name terminates with the zero length octet * for the null label of the root */ - if (lb_size == 0) { + if (lb_size == 0U) { rc = 0; break; } diff --git a/subsys/net/lib/dns/llmnr_responder.c b/subsys/net/lib/dns/llmnr_responder.c index c1388fdf8ac..b7dd4007f4d 100644 --- a/subsys/net/lib/dns/llmnr_responder.c +++ b/subsys/net/lib/dns/llmnr_responder.c @@ -472,7 +472,7 @@ static int dns_read(struct net_context *ctx, enum dns_class qclass; (void)memset(result->data, 0, result->size); - result->len = 0; + result->len = 0U; ret = dns_unpack_query(&dns_msg, result, &qtype, &qclass); if (ret < 0) { diff --git a/subsys/net/lib/dns/mdns_responder.c b/subsys/net/lib/dns/mdns_responder.c index 23eac9a167c..9bb63f18034 100644 --- a/subsys/net/lib/dns/mdns_responder.c +++ b/subsys/net/lib/dns/mdns_responder.c @@ -323,7 +323,7 @@ static int dns_read(struct net_context *ctx, u8_t *lquery; (void)memset(result->data, 0, net_buf_tailroom(result)); - result->len = 0; + result->len = 0U; ret = dns_unpack_query(&dns_msg, result, &qtype, &qclass); if (ret < 0) { diff --git a/subsys/net/lib/dns/resolve.c b/subsys/net/lib/dns/resolve.c index 472ee3684c9..f3ca2f41039 100644 --- a/subsys/net/lib/dns/resolve.c +++ b/subsys/net/lib/dns/resolve.c @@ -83,7 +83,7 @@ static bool server_is_mdns(sa_family_t family, struct sockaddr *addr) { if (family == AF_INET) { if (net_ipv4_is_addr_mcast(&net_sin(addr)->sin_addr) && - net_sin(addr)->sin_addr.s4_addr[3] == 251) { + net_sin(addr)->sin_addr.s4_addr[3] == 251U) { return true; } @@ -106,7 +106,7 @@ static bool server_is_llmnr(sa_family_t family, struct sockaddr *addr) { if (family == AF_INET) { if (net_ipv4_is_addr_mcast(&net_sin(addr)->sin_addr) && - net_sin(addr)->sin_addr.s4_addr[3] == 252) { + net_sin(addr)->sin_addr.s4_addr[3] == 252U) { return true; } @@ -136,7 +136,7 @@ static void dns_postprocess_server(struct dns_resolve_context *ctx, int idx) server_is_llmnr(AF_INET, addr); } - if (net_sin(addr)->sin_port == 0) { + if (net_sin(addr)->sin_port == 0U) { if (IS_ENABLED(CONFIG_MDNS_RESOLVER) && ctx->servers[idx].is_mdns) { /* We only use 5353 as a default port @@ -164,7 +164,7 @@ static void dns_postprocess_server(struct dns_resolve_context *ctx, int idx) server_is_llmnr(AF_INET6, addr); } - if (net_sin6(addr)->sin6_port == 0) { + if (net_sin6(addr)->sin6_port == 0U) { if (IS_ENABLED(CONFIG_MDNS_RESOLVER) && ctx->servers[idx].is_mdns) { net_sin6(addr)->sin6_port = htons(5353); diff --git a/subsys/net/lib/http/http_parser.c b/subsys/net/lib/http/http_parser.c index 554590edc3b..228ffb810b3 100644 --- a/subsys/net/lib/http/http_parser.c +++ b/subsys/net/lib/http/http_parser.c @@ -527,7 +527,7 @@ int header_states(struct http_parser *parser, const char *data, size_t len, } t = parser->content_length; - t *= 10; + t *= 10U; t += ch - '0'; /* Overflow? Test against a conservative limit for simplicity */ @@ -608,7 +608,7 @@ int header_states(struct http_parser *parser, const char *data, size_t len, case h_matching_connection_token: if (ch == ',') { h_state = h_matching_connection_token_start; - parser->index = 0; + parser->index = 0U; } break; @@ -630,7 +630,7 @@ int header_states(struct http_parser *parser, const char *data, size_t len, parser->flags |= F_CONNECTION_UPGRADE; } h_state = h_matching_connection_token_start; - parser->index = 0; + parser->index = 0U; } else if (ch != ' ') { h_state = h_matching_connection_token; } @@ -657,7 +657,7 @@ int zero_content_length(struct http_parser *parser, enum state p_state = *current_state; int rc; - if (parser->content_length == 0) { + if (parser->content_length == 0U) { /* Content-Length header given but zero: * Content-Length: 0\r\n */ @@ -806,7 +806,7 @@ reexecute: if (ch == CR || ch == LF) { break; } - parser->flags = 0; + parser->flags = 0U; parser->content_length = ULLONG_MAX; if (ch == 'H') { @@ -840,13 +840,13 @@ reexecute: parser->type = HTTP_REQUEST; parser->method = HTTP_HEAD; - parser->index = 2; + parser->index = 2U; UPDATE_STATE(s_req_method); } break; case s_start_res: { - parser->flags = 0; + parser->flags = 0U; parser->content_length = ULLONG_MAX; switch (ch) { @@ -928,7 +928,7 @@ reexecute: goto error; } - parser->http_major *= 10; + parser->http_major *= 10U; parser->http_major += ch - '0'; if (UNLIKELY(parser->http_major > 999)) { @@ -962,7 +962,7 @@ reexecute: goto error; } - parser->http_minor *= 10; + parser->http_minor *= 10U; parser->http_minor += ch - '0'; if (UNLIKELY(parser->http_minor > 999)) { @@ -1006,7 +1006,7 @@ reexecute: break; } - parser->status_code *= 10; + parser->status_code *= 10U; parser->status_code += ch - '0'; if (UNLIKELY(parser->status_code > 999)) { @@ -1030,7 +1030,7 @@ reexecute: MARK(status); UPDATE_STATE(s_res_status); - parser->index = 0; + parser->index = 0U; break; } @@ -1074,7 +1074,7 @@ reexecute: if (ch == CR || ch == LF) { break; } - parser->flags = 0; + parser->flags = 0U; parser->content_length = ULLONG_MAX; if (UNLIKELY(!IS_ALPHA(ch))) { @@ -1083,7 +1083,7 @@ reexecute: } parser->method = (enum http_method) 0; - parser->index = 1; + parser->index = 1U; switch (ch) { case 'A': parser->method = HTTP_ACL; @@ -1228,7 +1228,7 @@ reexecute: goto error; } } else if (ch == '-' && - parser->index == 1 && + parser->index == 1U && parser->method == HTTP_MKCOL) { parser->method = HTTP_MSEARCH; } else { @@ -1303,8 +1303,8 @@ reexecute: break; case CR: case LF: - parser->http_major = 0; - parser->http_minor = 9; + parser->http_major = 0U; + parser->http_minor = 9U; UPDATE_STATE((ch == CR) ? s_req_line_almost_done : s_header_field_start); @@ -1396,7 +1396,7 @@ reexecute: goto error; } - parser->http_major *= 10; + parser->http_major *= 10U; parser->http_major += ch - '0'; if (UNLIKELY(parser->http_major > 999)) { @@ -1437,7 +1437,7 @@ reexecute: goto error; } - parser->http_minor *= 10; + parser->http_minor *= 10U; parser->http_minor += ch - '0'; if (UNLIKELY(parser->http_minor > 999)) { @@ -1483,7 +1483,7 @@ reexecute: MARK(header_field); - parser->index = 0; + parser->index = 0U; UPDATE_STATE(s_header_field); switch (c) { @@ -1575,7 +1575,7 @@ reexecute: MARK(header_value); UPDATE_STATE(s_header_value); - parser->index = 0; + parser->index = 0U; c = LOWER(ch); @@ -1857,7 +1857,7 @@ reexecute: break; case 2: - parser->upgrade = 1; + parser->upgrade = 1U; case 1: parser->flags |= F_SKIPBODY; @@ -1889,7 +1889,7 @@ reexecute: goto error; } - parser->nread = 0; + parser->nread = 0U; hasBody = parser->flags & F_CHUNKED || (parser->content_length > 0 && @@ -1946,7 +1946,7 @@ reexecute: u64_t to_read = MIN(parser->content_length, (u64_t) ((data + len) - p)); - assert(parser->content_length != 0 + assert(parser->content_length != 0U && parser->content_length != ULLONG_MAX); /* The difference between advancing content_length and @@ -1962,7 +1962,7 @@ reexecute: parser->content_length -= to_read; p += to_read - 1; - if (parser->content_length == 0) { + if (parser->content_length == 0U) { UPDATE_STATE(s_message_done); /* Mimic CALLBACK_DATA_NOADVANCE() but with one @@ -2024,7 +2024,7 @@ reexecute: break; case s_chunk_size_start: { - assert(parser->nread == 1); + assert(parser->nread == 1U); assert(parser->flags & F_CHUNKED); unhex_val = unhex[(unsigned char)ch]; @@ -2061,7 +2061,7 @@ reexecute: } t = parser->content_length; - t *= 16; + t *= 16U; t += unhex_val; /* Overflow? Test against a conservative limit for @@ -2096,9 +2096,9 @@ reexecute: goto error; } - parser->nread = 0; + parser->nread = 0U; - if (parser->content_length == 0) { + if (parser->content_length == 0U) { parser->flags |= F_TRAILING; UPDATE_STATE(s_header_field_start); } else { @@ -2120,7 +2120,7 @@ reexecute: (u64_t) ((data + len) - p)); assert(parser->flags & F_CHUNKED); - assert(parser->content_length != 0 + assert(parser->content_length != 0U && parser->content_length != ULLONG_MAX); /* See the explanation in s_body_identity for why the @@ -2131,7 +2131,7 @@ reexecute: parser->content_length -= to_read; p += to_read - 1; - if (parser->content_length == 0) { + if (parser->content_length == 0U) { UPDATE_STATE(s_chunk_data_almost_done); } @@ -2140,7 +2140,7 @@ reexecute: case s_chunk_data_almost_done: assert(parser->flags & F_CHUNKED); - assert(parser->content_length == 0); + assert(parser->content_length == 0U); rc = strict_check(parser, ch != CR); if (rc != 0) { goto error; @@ -2161,7 +2161,7 @@ reexecute: if (rc != 0) { goto error; } - parser->nread = 0; + parser->nread = 0U; UPDATE_STATE(s_chunk_size_start); rc = cb_notify(parser, &p_state, @@ -2259,9 +2259,9 @@ int http_message_needs_eof(const struct http_parser *parser) } /* See RFC 2616 section 4.4 */ - if (parser->status_code / 100 == 1 || /* 1xx e.g. Continue */ - parser->status_code == 204 || /* No Content */ - parser->status_code == 304 || /* Not Modified */ + if (parser->status_code / 100 == 1U || /* 1xx e.g. Continue */ + parser->status_code == 204U || /* No Content */ + parser->status_code == 304U || /* Not Modified */ parser->flags & F_SKIPBODY) { /* response to a HEAD * request */ diff --git a/subsys/net/lib/http/http_parser_url.c b/subsys/net/lib/http/http_parser_url.c index 0ca33ddfa1c..f74c0c5608c 100644 --- a/subsys/net/lib/http/http_parser_url.c +++ b/subsys/net/lib/http/http_parser_url.c @@ -386,7 +386,7 @@ int http_parse_host(const char *buf, struct http_parser_url *u, buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len; assert(u->field_set & (1 << UF_HOST)); - u->field_data[UF_HOST].len = 0; + u->field_data[UF_HOST].len = 0U; s = found_at ? s_http_userinfo_start : s_http_host_start; @@ -420,7 +420,7 @@ int http_parse_host(const char *buf, struct http_parser_url *u, case s_http_host_port: if (s != s_http_host_port) { u->field_data[UF_PORT].off = p - buf; - u->field_data[UF_PORT].len = 0; + u->field_data[UF_PORT].len = 0U; u->field_set |= (1 << UF_PORT); } u->field_data[UF_PORT].len++; @@ -429,7 +429,7 @@ int http_parse_host(const char *buf, struct http_parser_url *u, case s_http_userinfo: if (s != s_http_userinfo) { u->field_data[UF_USERINFO].off = p - buf; - u->field_data[UF_USERINFO].len = 0; + u->field_data[UF_USERINFO].len = 0U; u->field_set |= (1 << UF_USERINFO); } u->field_data[UF_USERINFO].len++; @@ -475,7 +475,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect, const char *p; enum state s; - u->port = u->field_set = 0; + u->port = u->field_set = 0U; s = is_connect ? s_req_server_start : s_req_spaces_before_url; old_uf = UF_MAX; @@ -531,7 +531,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect, } u->field_data[uf].off = p - buf; - u->field_data[uf].len = 1; + u->field_data[uf].len = 1U; u->field_set |= (1 << uf); old_uf = uf; @@ -540,7 +540,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect, /* host must be present if there is a schema */ /* parsing http:///toto will fail */ if ((u->field_set & (1 << UF_SCHEMA)) && - (u->field_set & (1 << UF_HOST)) == 0) { + (u->field_set & (1 << UF_HOST)) == 0U) { return 1; } diff --git a/subsys/net/lib/lwm2m/ipso_light_control.c b/subsys/net/lib/lwm2m/ipso_light_control.c index a8bc92ab22b..ada9b05ec42 100644 --- a/subsys/net/lib/lwm2m/ipso_light_control.c +++ b/subsys/net/lib/lwm2m/ipso_light_control.c @@ -90,7 +90,7 @@ static int on_time_post_write_cb(u16_t obj_inst_id, { int i; - if (data_len != 4) { + if (data_len != 4U) { LOG_ERR("unknown size %u", data_len); return -EINVAL; } diff --git a/subsys/net/lib/lwm2m/ipso_timer.c b/subsys/net/lib/lwm2m/ipso_timer.c index f70c74cfe62..cb940e6caaa 100644 --- a/subsys/net/lib/lwm2m/ipso_timer.c +++ b/subsys/net/lib/lwm2m/ipso_timer.c @@ -140,7 +140,7 @@ static int start_timer(struct ipso_timer_data *timer) /* TODO: check delay_duration > 0 ? other modes can it be 0? */ timer->trigger_offset = k_uptime_get(); - timer->trigger_counter += 1; + timer->trigger_counter += 1U; snprintk(path, MAX_RESOURCE_LEN, "%d/%u/%d", IPSO_OBJECT_TIMER_ID, timer->obj_inst_id, TIMER_DIGITAL_STATE_ID); diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index 45ac33ef9bf..c38fd787ee8 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -199,8 +199,8 @@ char *lwm2m_sprint_ip_addr(const struct sockaddr *addr) static u8_t to_hex_digit(u8_t digit) { - if (digit >= 10) { - return digit - 10 + 'a'; + if (digit >= 10U) { + return digit - 10U + 'a'; } return digit + '0'; @@ -264,7 +264,7 @@ init_block_ctx(const u8_t *token, u8_t tkl, struct block_context **ctx) *ctx = NULL; timestamp = k_uptime_get(); for (i = 0; i < NUM_BLOCK1_CONTEXT; i++) { - if (block1_contexts[i].tkl == 0) { + if (block1_contexts[i].tkl == 0U) { *ctx = &block1_contexts[i]; break; } @@ -428,7 +428,7 @@ static int engine_add_observer(struct lwm2m_message *msg, return -EINVAL; } - if (!token || (tkl == 0 || tkl > MAX_TOKEN_LEN)) { + if (!token || (tkl == 0U || tkl > MAX_TOKEN_LEN)) { LOG_ERR("token(%p) and token length(%u) must be valid.", token, tkl); return -EINVAL; @@ -469,7 +469,7 @@ static int engine_add_observer(struct lwm2m_message *msg, } /* check if object instance exists */ - if (msg->path.level >= 2) { + if (msg->path.level >= 2U) { obj_inst = get_engine_obj_inst(msg->path.obj_id, msg->path.obj_inst_id); if (!obj_inst) { @@ -485,7 +485,7 @@ static int engine_add_observer(struct lwm2m_message *msg, } /* check if resource exists */ - if (msg->path.level >= 3) { + if (msg->path.level >= 3U) { for (i = 0; i < obj_inst->resource_count; i++) { if (obj_inst->resources[i].res_id == msg->path.res_id) { break; @@ -561,7 +561,7 @@ static int engine_remove_observer(const u8_t *token, u8_t tkl) struct observe_node *obs, *found_obj = NULL; sys_snode_t *prev_node = NULL; - if (!token || (tkl == 0 || tkl > MAX_TOKEN_LEN)) { + if (!token || (tkl == 0U || tkl > MAX_TOKEN_LEN)) { LOG_ERR("token(%p) and token length(%u) must be valid.", token, tkl); return -EINVAL; @@ -816,7 +816,7 @@ static u16_t atou16(u8_t *buf, u16_t buflen, u16_t *len) /* we should get a value first - consume all numbers */ while (pos < buflen && isdigit(buf[pos])) { - val = val * 10 + (buf[pos] - '0'); + val = val * 10U + (buf[pos] - '0'); pos++; } @@ -878,7 +878,7 @@ static int coap_options_to_path(struct coap_option *opt, int options_count, for (int i = 0; i < options_count; i++) { *id[i] = atou16(opt[i].value, opt[i].len, &len); - if (len == 0 || opt[i].len != len) { + if (len == 0U || opt[i].len != len) { path->level = i; break; } @@ -961,7 +961,7 @@ int lwm2m_init_message(struct lwm2m_message *msg) * msg->tkl == 0 is for a new TOKEN * msg->tkl == LWM2M_MSG_TOKEN_LEN_SKIP means dont set */ - if (msg->tkl == 0) { + if (msg->tkl == 0U) { tokenlen = 0U; token = coap_next_token(); } else if (msg->token && msg->tkl != LWM2M_MSG_TOKEN_LEN_SKIP) { @@ -1077,7 +1077,7 @@ u16_t lwm2m_get_rd_data(u8_t *client_data, u16_t size) } /* Only report when no instance available */ - if (obj->instance_count == 0) { + if (obj->instance_count == 0U) { len = snprintk(temp, sizeof(temp), "%s", (pos > 0) ? "," : "", obj->obj_id); if (pos + len >= size) { @@ -1271,7 +1271,7 @@ static int path_to_objs(const struct lwm2m_obj_path *path, return -ENOENT; } - if (!oi->resources || oi->resource_count == 0) { + if (!oi->resources || oi->resource_count == 0U) { LOG_ERR("obj instance has no resources"); return -EINVAL; } @@ -1323,7 +1323,7 @@ int lwm2m_engine_create_obj_inst(char *pathstr) return ret; } - if (path.level != 2) { + if (path.level != 2U) { LOG_ERR("path must have 2 parts"); return -EINVAL; } @@ -1943,7 +1943,7 @@ static int lwm2m_read_handler(struct lwm2m_engine_obj_inst *obj_inst, if (res->multi_count_var != NULL) { /* if multi_count_var is 0 (none assigned) return NOT_FOUND */ - if (*res->multi_count_var == 0) { + if (*res->multi_count_var == 0U) { return -ENOENT; } @@ -2052,7 +2052,7 @@ size_t lwm2m_engine_get_opaque_more(struct lwm2m_input_context *in, } in->opaque_len -= in_len; - if (in->opaque_len == 0) { + if (in->opaque_len == 0U) { *last_block = true; } @@ -2304,16 +2304,16 @@ static int lwm2m_write_attr_handler(struct lwm2m_engine_obj *obj, } /* get lwm2m_attr slist */ - if (msg->path.level == 3) { + if (msg->path.level == 3U) { ret = path_to_objs(&msg->path, NULL, NULL, &res); if (ret < 0) { return ret; } ref = res; - } else if (msg->path.level == 1) { + } else if (msg->path.level == 1U) { ref = obj; - } else if (msg->path.level == 2) { + } else if (msg->path.level == 2U) { obj_inst = get_engine_obj_inst(msg->path.obj_id, msg->path.obj_inst_id); if (!obj_inst) { @@ -2373,7 +2373,7 @@ static int lwm2m_write_attr_handler(struct lwm2m_engine_obj *obj, } /* gt/lt/st cannot be assigned to obj/obj_inst unless unset */ - if (plen == 2 && msg->path.level <= 2) { + if (plen == 2 && msg->path.level <= 2U) { return -EEXIST; } @@ -2681,10 +2681,10 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj, int ret = 0, index; u8_t num_read = 0U; - if (msg->path.level >= 2) { + if (msg->path.level >= 2U) { obj_inst = get_engine_obj_inst(msg->path.obj_id, msg->path.obj_inst_id); - } else if (msg->path.level == 1) { + } else if (msg->path.level == 1U) { /* find first obj_inst with path's obj_id */ obj_inst = next_engine_obj_inst(msg->path.obj_id, -1); } @@ -2713,14 +2713,14 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj, engine_put_begin(&msg->out, &msg->path); while (obj_inst) { - if (!obj_inst->resources || obj_inst->resource_count == 0) { + if (!obj_inst->resources || obj_inst->resource_count == 0U) { goto move_forward; } /* update the obj_inst_id as we move through the instances */ msg->path.obj_inst_id = obj_inst->obj_inst_id; - if (msg->path.level <= 1) { + if (msg->path.level <= 1U) { /* start instance formatting */ engine_put_begin_oi(&msg->out, &msg->path); } @@ -2761,7 +2761,7 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj, LOG_ERR("READ OP: %d", ret); } } else { - num_read += 1; + num_read += 1U; } /* end resource formatting */ @@ -2778,12 +2778,12 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj, } move_forward: - if (msg->path.level <= 1) { + if (msg->path.level <= 1U) { /* end instance formatting */ engine_put_end_oi(&msg->out, &msg->path); } - if (msg->path.level <= 1) { + if (msg->path.level <= 1U) { /* advance to the next object instance */ obj_inst = next_engine_obj_inst(msg->path.obj_id, obj_inst->obj_inst_id); @@ -2798,7 +2798,7 @@ move_forward: memcpy(&msg->path, &temp_path, sizeof(temp_path)); /* did not read anything even if we should have - on single item */ - if (ret == 0 && num_read == 0 && msg->path.level == 3) { + if (ret == 0 && num_read == 0U && msg->path.level == 3U) { return -ENOENT; } @@ -2861,7 +2861,7 @@ static int do_discover_op(struct lwm2m_message *msg, bool well_known) * ref: lwm2m spec 20170208-A table 11 */ if (!msg->ctx->bootstrap_mode && !well_known && - (msg->path.level == 0 || + (msg->path.level == 0U || (msg->path.level > 0 && msg->path.obj_id == LWM2M_OBJECT_SECURITY_ID))) { return -EPERM; @@ -2923,7 +2923,7 @@ static int do_discover_op(struct lwm2m_message *msg, bool well_known) continue; } - if (msg->path.level == 1) { + if (msg->path.level == 1U) { snprintk(disc_buf, sizeof(disc_buf), "%s", reported ? "," : "", obj_inst->obj->obj_id); @@ -2950,7 +2950,7 @@ static int do_discover_op(struct lwm2m_message *msg, bool well_known) continue; } - if (msg->path.level == 2) { + if (msg->path.level == 2U) { snprintk(disc_buf, sizeof(disc_buf), "%s", reported ? "," : "", obj_inst->obj->obj_id, obj_inst->obj_inst_id); @@ -2978,7 +2978,7 @@ static int do_discover_op(struct lwm2m_message *msg, bool well_known) for (int i = 0; i < obj_inst->resource_count; i++) { /* skip unrelated resources */ - if (msg->path.level == 3 && + if (msg->path.level == 3U && msg->path.res_id != obj_inst->resources[i].res_id) { continue; } @@ -3166,9 +3166,9 @@ static int handle_request(struct coap_packet *request, /* check for .well-known/core URI query (DISCOVER) */ if (r == 2 && - (options[0].len == 11 && + (options[0].len == 11U && strncmp(options[0].value, ".well-known", 11) == 0) && - (options[1].len == 4 && + (options[1].len == 4U && strncmp(options[1].value, "core", 4) == 0)) { if ((code & COAP_REQUEST_MASK) != COAP_METHOD_GET) { r = -EPERM; @@ -3240,11 +3240,11 @@ static int handle_request(struct coap_packet *request, break; case COAP_METHOD_POST: - if (msg->path.level == 1) { + if (msg->path.level == 1U) { /* create an object instance */ msg->operation = LWM2M_OP_CREATE; msg->code = COAP_RESPONSE_CODE_CREATED; - } else if (msg->path.level == 2) { + } else if (msg->path.level == 2U) { /* write values to an object instance */ msg->operation = LWM2M_OP_WRITE; msg->code = COAP_RESPONSE_CODE_CHANGED; @@ -3756,7 +3756,7 @@ int lwm2m_engine_add_service(k_work_handler_t service, u32_t period_ms) k_work_init(&service_node_data[i].service_work, service); service_node_data[i].min_call_period = period_ms; - service_node_data[i].last_timestamp = 0; + service_node_data[i].last_timestamp = 0U; sys_slist_append(&engine_service_list, &service_node_data[i].node); @@ -3948,7 +3948,7 @@ static void socket_receive_loop(void) continue; } - in_buf[len] = 0; + in_buf[len] = 0U; lwm2m_udp_receive(sock_ctx[i], in_buf, len, &from_addr, handle_request); @@ -4077,7 +4077,7 @@ int lwm2m_parse_peerinfo(char *url, struct sockaddr *addr, bool *use_dtls) /* check for DTLS requirement */ *use_dtls = false; - if (len == 5 && strncmp(url + off, "coaps", len) == 0) { + if (len == 5U && strncmp(url + off, "coaps", len) == 0) { #if defined(CONFIG_LWM2M_DTLS_SUPPORT) *use_dtls = true; #else diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_device.c b/subsys/net/lib/lwm2m/lwm2m_obj_device.c index b5277f4d248..b4a1bbc2cec 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_device.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_device.c @@ -155,7 +155,7 @@ static int current_time_post_write_cb(u16_t obj_inst_id, u8_t *data, u16_t data_len, bool last_block, size_t total_size) { - if (data_len == 4) { + if (data_len == 4U) { time_offset = *(s32_t *)data - (s32_t)(k_uptime_get() / 1000); return 0; } diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c b/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c index 7cd066a5f69..809464ac19d 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c @@ -193,7 +193,7 @@ static int package_write_cb(u16_t obj_inst_id, */ lwm2m_firmware_set_update_state(STATE_DOWNLOADING); } else if (state != STATE_DOWNLOADING) { - if (data_len == 0 && state == STATE_DOWNLOADED) { + if (data_len == 0U && state == STATE_DOWNLOADED) { /* reset to state idle and result default */ lwm2m_firmware_set_update_result(RESULT_DEFAULT); return 0; @@ -239,7 +239,7 @@ static int package_uri_write_cb(u16_t obj_inst_id, if (state == STATE_IDLE) { lwm2m_firmware_set_update_result(RESULT_DEFAULT); lwm2m_firmware_start_transfer(package_uri); - } else if (state == STATE_DOWNLOADED && data_len == 0) { + } else if (state == STATE_DOWNLOADED && data_len == 0U) { /* reset to state idle and result default */ lwm2m_firmware_set_update_result(RESULT_DEFAULT); } diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_security.c b/subsys/net/lib/lwm2m/lwm2m_obj_security.c index eae2a54df08..8e4b3d66da1 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_security.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_security.c @@ -98,8 +98,8 @@ static struct lwm2m_engine_obj_inst *security_create(u16_t obj_inst_id) security_uri[index][0] = '\0'; client_identity[index][0] = '\0'; bootstrap_flag[index] = 0; - security_mode[index] = 0; - short_server_id[index] = 0; + security_mode[index] = 0U; + short_server_id[index] = 0U; /* initialize instance resource data */ INIT_OBJ_RES_DATA(res[index], i, SECURITY_SERVER_URI_ID, diff --git a/subsys/net/lib/lwm2m/lwm2m_rw_json.c b/subsys/net/lib/lwm2m/lwm2m_rw_json.c index bb2a87ca037..938d4f65ecb 100644 --- a/subsys/net/lib/lwm2m/lwm2m_rw_json.c +++ b/subsys/net/lib/lwm2m/lwm2m_rw_json.c @@ -128,12 +128,12 @@ static void json_add_char(struct lwm2m_input_context *in, !(fd->json_flags & T_STRING_END))) { if (fd->json_flags & T_VALUE) { fd->value_len++; - if (fd->value_len == 1) { + if (fd->value_len == 1U) { fd->value_offset = fd->offset; } } else { fd->name_len++; - if (fd->name_len == 1) { + if (fd->name_len == 1U) { fd->name_offset = fd->offset; } } @@ -170,7 +170,7 @@ static int json_next_token(struct lwm2m_input_context *in, case '[': if (!escape) { fd->json_flags |= T_OBJECT_BEGIN; - cont = 0; + cont = 0U; } else { json_add_char(in, fd); } @@ -178,7 +178,7 @@ static int json_next_token(struct lwm2m_input_context *in, case ']': if (!escape) { fd->json_flags |= T_OBJECT_END; - cont = 0; + cont = 0U; } else { json_add_char(in, fd); } @@ -195,7 +195,7 @@ static int json_next_token(struct lwm2m_input_context *in, case '}': case ',': if (!escape) { - cont = 0; + cont = 0U; } else { json_add_char(in, fd); } @@ -248,7 +248,7 @@ static int json_next_token(struct lwm2m_input_context *in, } /* OK if cont == 0 othewise we failed */ - return (cont == 0); + return (cont == 0U); } static size_t put_begin(struct lwm2m_output_context *out, @@ -256,7 +256,7 @@ static size_t put_begin(struct lwm2m_output_context *out, { int len = -1; - if (path->level >= 2) { + if (path->level >= 2U) { len = snprintk(json_buffer, sizeof(json_buffer), "{\"bn\":\"/%u/%u/\",\"e\":[", path->obj_id, path->obj_inst_id); @@ -344,7 +344,7 @@ static size_t put_json_prefix(struct lwm2m_output_context *out, } sep = SEPARATOR(fd->writer_flags); - if (fd->path_level >= 2) { + if (fd->path_level >= 2U) { if (fd->writer_flags & WRITER_RESOURCE_INSTANCE) { len = snprintk(json_buffer, sizeof(json_buffer), "%s{\"n\":\"%u/%u\",%s:", @@ -732,7 +732,7 @@ static int parse_path(const u8_t *buf, u16_t buflen, c = buf[pos]; /* we should get a value first - consume all numbers */ while (pos < buflen && isdigit(c)) { - val = val * 10 + (c - '0'); + val = val * 10U + (c - '0'); c = buf[++pos]; } @@ -811,7 +811,7 @@ int do_write_op_json(struct lwm2m_engine_obj *obj, struct lwm2m_message *msg) /* handle resource name */ if (value[0] == 'n') { /* reset values */ - created = 0; + created = 0U; /* get value for relative path */ if (buf_read(value, fd.value_len, @@ -863,7 +863,7 @@ int do_write_op_json(struct lwm2m_engine_obj *obj, struct lwm2m_message *msg) } if (!obj_inst->resources || - obj_inst->resource_count == 0) { + obj_inst->resource_count == 0U) { ret = -EINVAL; break; } @@ -885,7 +885,7 @@ int do_write_op_json(struct lwm2m_engine_obj *obj, struct lwm2m_message *msg) /* handle value assignment */ ret = lwm2m_write_handler(obj_inst, res, obj_field, msg); - if (orig_path.level == 3 && ret < 0) { + if (orig_path.level == 3U && ret < 0) { /* return errors on a single write */ break; } diff --git a/subsys/net/lib/lwm2m/lwm2m_rw_oma_tlv.c b/subsys/net/lib/lwm2m/lwm2m_rw_oma_tlv.c index c5d84f60ae0..84b7c90325c 100644 --- a/subsys/net/lib/lwm2m/lwm2m_rw_oma_tlv.c +++ b/subsys/net/lib/lwm2m/lwm2m_rw_oma_tlv.c @@ -174,7 +174,7 @@ static size_t oma_tlv_put(const struct oma_tlv *tlv, tmp = (tlv->type << 6) | (tlv->id > 255 ? (1 << 5) : 0) | (len_type << 3) | - (len_type == 0 ? tlv->length : 0); + (len_type == 0U ? tlv->length : 0); ret = oma_tlv_put_u8(out, tmp, insert); if (ret < 0) { @@ -246,7 +246,7 @@ static size_t oma_tlv_get(struct oma_tlv *tlv, tlv->type = (buf[0] >> 6) & 3; len_type = (buf[0] >> 3) & 3; - len_pos = 1 + (((buf[0] & (1 << 5)) != 0) ? 2 : 1); + len_pos = 1 + (((buf[0] & (1 << 5)) != 0U) ? 2 : 1); if (buf_read_u8(&buf[1], CPKT_BUF_READ(in->in_cpkt), &tmp_offset) < 0) { return 0; @@ -264,7 +264,7 @@ static size_t oma_tlv_get(struct oma_tlv *tlv, tlv->id = (tlv->id << 8) + buf[1]; } - if (len_type == 0) { + if (len_type == 0U) { tlv_len = buf[0] & 7; } else { /* read the length */ @@ -654,7 +654,7 @@ static size_t get_float32fix(struct lwm2m_input_context *in, int ret; if (size > 0) { - if (tlv.length != 4) { + if (tlv.length != 4U) { LOG_ERR("Invalid float32 length: %d", tlv.length); /* dummy read */ @@ -695,7 +695,7 @@ static size_t get_float64fix(struct lwm2m_input_context *in, int ret; if (size > 0) { - if (tlv.length != 8) { + if (tlv.length != 8U) { LOG_ERR("invalid float64 length: %d", tlv.length); /* dummy read */ @@ -830,7 +830,7 @@ static int do_write_op_tlv_item(struct lwm2m_message *msg) goto error; } - if (!obj_inst->resources || obj_inst->resource_count == 0) { + if (!obj_inst->resources || obj_inst->resource_count == 0U) { ret = -EINVAL; goto error; } @@ -893,7 +893,7 @@ int do_write_op_tlv(struct lwm2m_engine_obj *obj, struct lwm2m_message *msg) oma_tlv_get(&tlv, &msg->in, false); msg->path.obj_inst_id = tlv.id; - if (tlv.length == 0) { + if (tlv.length == 0U) { /* Create only - no data */ ret = lwm2m_create_obj_inst( msg->path.obj_id, @@ -918,7 +918,7 @@ int do_write_op_tlv(struct lwm2m_engine_obj *obj, struct lwm2m_message *msg) } msg->path.res_id = tlv2.id; - msg->path.level = 3; + msg->path.level = 3U; ret = do_write_op_tlv_item(msg); /* * ignore errors for CREATE op @@ -936,7 +936,7 @@ int do_write_op_tlv(struct lwm2m_engine_obj *obj, struct lwm2m_message *msg) } } else if (tlv.type == OMA_TLV_TYPE_RESOURCE) { msg->path.res_id = tlv.id; - msg->path.level = 3; + msg->path.level = 3U; ret = do_write_op_tlv_item(msg); /* * ignore errors for CREATE op diff --git a/subsys/net/lib/lwm2m/lwm2m_rw_plain_text.c b/subsys/net/lib/lwm2m/lwm2m_rw_plain_text.c index f62a7a3a086..702fbb6754a 100644 --- a/subsys/net/lib/lwm2m/lwm2m_rw_plain_text.c +++ b/subsys/net/lib/lwm2m/lwm2m_rw_plain_text.c @@ -320,7 +320,7 @@ int do_read_op_plain_text(struct lwm2m_engine_obj *obj, struct lwm2m_message *msg, int content_format) { /* Plain text can only return single resource */ - if (msg->path.level != 3) { + if (msg->path.level != 3U) { return -EPERM; /* NOT_ALLOWED */ } @@ -350,7 +350,7 @@ int do_write_op_plain_text(struct lwm2m_engine_obj *obj, return -EPERM; } - if (!obj_inst->resources || obj_inst->resource_count == 0) { + if (!obj_inst->resources || obj_inst->resource_count == 0U) { return -EINVAL; } @@ -365,6 +365,6 @@ int do_write_op_plain_text(struct lwm2m_engine_obj *obj, return -ENOENT; } - msg->path.level = 3; + msg->path.level = 3U; return lwm2m_write_handler(obj_inst, res, obj_field, msg); } diff --git a/subsys/net/lib/mqtt/mqtt.c b/subsys/net/lib/mqtt/mqtt.c index 4d678abcd99..be7523ace12 100644 --- a/subsys/net/lib/mqtt/mqtt.c +++ b/subsys/net/lib/mqtt/mqtt.c @@ -22,9 +22,9 @@ static void client_reset(struct mqtt_client *client) { MQTT_STATE_INIT(client); - client->internal.last_activity = 0; - client->internal.rx_buf_datalen = 0; - client->internal.remaining_payload = 0; + client->internal.last_activity = 0U; + client->internal.rx_buf_datalen = 0U; + client->internal.remaining_payload = 0U; } /** @brief Initialize tx buffer. */ @@ -167,7 +167,7 @@ void mqtt_client_init(struct mqtt_client *client) mqtt_mutex_init(client); client->protocol_version = MQTT_VERSION_3_1_1; - client->clean_session = 1; + client->clean_session = 1U; } int mqtt_connect(struct mqtt_client *client) @@ -605,7 +605,7 @@ int mqtt_read_publish_payload(struct mqtt_client *client, void *buffer, mqtt_mutex_lock(client); - if (client->internal.remaining_payload == 0) { + if (client->internal.remaining_payload == 0U) { ret = 0; goto exit; } diff --git a/subsys/net/lib/mqtt/mqtt_decoder.c b/subsys/net/lib/mqtt/mqtt_decoder.c index 67a71ec2ac4..36fbc8aef8e 100644 --- a/subsys/net/lib/mqtt/mqtt_decoder.c +++ b/subsys/net/lib/mqtt/mqtt_decoder.c @@ -177,7 +177,7 @@ int packet_length_decode(struct buf_ctx *buf, u32_t *length) << shift; shift += MQTT_LENGTH_SHIFT; bytes++; - } while ((*(buf->cur++) & MQTT_LENGTH_CONTINUATION_BIT) != 0); + } while ((*(buf->cur++) & MQTT_LENGTH_CONTINUATION_BIT) != 0U); MQTT_TRC("length:0x%08x", *length); diff --git a/subsys/net/lib/mqtt/mqtt_encoder.c b/subsys/net/lib/mqtt/mqtt_encoder.c index 899a90d96a3..28e5b4005d0 100644 --- a/subsys/net/lib/mqtt/mqtt_encoder.c +++ b/subsys/net/lib/mqtt/mqtt_encoder.c @@ -264,7 +264,7 @@ static int mqtt_message_id_only_enc(u8_t message_type, u16_t message_id, u8_t *start; /* Message id zero is not permitted by spec. */ - if (message_id == 0) { + if (message_id == 0U) { return -EINVAL; } @@ -409,7 +409,7 @@ int publish_encode(const struct mqtt_publish_param *param, struct buf_ctx *buf) u8_t *start; /* Message id zero is not permitted by spec. */ - if ((param->message.topic.qos) && (param->message_id == 0)) { + if ((param->message.topic.qos) && (param->message_id == 0U)) { return -EINVAL; } @@ -501,7 +501,7 @@ int subscribe_encode(const struct mqtt_subscription_list *param, u8_t *start; /* Message id zero is not permitted by spec. */ - if (param->message_id == 0) { + if (param->message_id == 0U) { return -EINVAL; } diff --git a/subsys/net/lib/mqtt/mqtt_rx.c b/subsys/net/lib/mqtt/mqtt_rx.c index 109ad187178..b4c4da37702 100644 --- a/subsys/net/lib/mqtt/mqtt_rx.c +++ b/subsys/net/lib/mqtt/mqtt_rx.c @@ -273,7 +273,7 @@ int mqtt_handle_rx(struct mqtt_client *client) return err_code; } - client->internal.rx_buf_datalen = 0; + client->internal.rx_buf_datalen = 0U; return 0; } diff --git a/subsys/net/lib/sockets/sockets_select.c b/subsys/net/lib/sockets/sockets_select.c index dc964800fac..62ac1d9b199 100644 --- a/subsys/net/lib/sockets/sockets_select.c +++ b/subsys/net/lib/sockets/sockets_select.c @@ -21,7 +21,7 @@ void ZSOCK_FD_ZERO(zsock_fd_set *set) int i; for (i = 0; i < ARRAY_SIZE(set->bitset); i++) { - set->bitset[i] = 0; + set->bitset[i] = 0U; } } @@ -35,7 +35,7 @@ int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set) FD_SET_CALC_OFFSETS(set, word_idx, bit_mask); - return (set->bitset[word_idx] & bit_mask) != 0; + return (set->bitset[word_idx] & bit_mask) != 0U; } void ZSOCK_FD_CLR(int fd, zsock_fd_set *set) @@ -74,8 +74,8 @@ int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds, int fd_no = 0; for (i = 0; i < STRUCT_MEMBER_ARRAY_SIZE(zsock_fd_set, bitset); i++) { - u32_t bit_mask = 1; - u32_t read_mask = 0, write_mask = 0, except_mask = 0; + u32_t bit_mask = 1U; + u32_t read_mask = 0U, write_mask = 0U, except_mask = 0U; u32_t ored_mask; if (readfds != NULL) { @@ -91,7 +91,7 @@ int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds, } ored_mask = read_mask | write_mask | except_mask; - if (ored_mask == 0) { + if (ored_mask == 0U) { continue; } @@ -122,7 +122,7 @@ int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds, bit_mask <<= 1; fd_no++; - } while (bit_mask != 0); + } while (bit_mask != 0U); } poll_timeout = -1; diff --git a/subsys/net/lib/sockets/sockets_tls.c b/subsys/net/lib/sockets/sockets_tls.c index 9d04b427e7d..b015d13ef2f 100644 --- a/subsys/net/lib/sockets/sockets_tls.c +++ b/subsys/net/lib/sockets/sockets_tls.c @@ -213,7 +213,7 @@ static void dtls_timing_set_delay(void *data, uint32_t int_ms, uint32_t fin_ms) ctx->int_ms = int_ms; ctx->fin_ms = fin_ms; - if (fin_ms != 0) { + if (fin_ms != 0U) { ctx->snapshot = k_uptime_get_32(); } } @@ -232,7 +232,7 @@ static int dtls_timing_get_delay(void *data) NET_ASSERT(timing); - if (timing->fin_ms == 0) { + if (timing->fin_ms == 0U) { return -1; } @@ -480,7 +480,7 @@ static int dtls_rx(void *ctx, unsigned char *buf, size_t len, uint32_t timeout) struct net_context *net_ctx = ctx; bool is_block = !((net_ctx->tls->flags & ZSOCK_MSG_DONTWAIT) || sock_is_nonblock(net_ctx)); - int remaining_time = (timeout == 0) ? K_FOREVER : timeout; + int remaining_time = (timeout == 0U) ? K_FOREVER : timeout; u32_t entry_time = k_uptime_get_32(); socklen_t addrlen = sizeof(struct sockaddr); struct sockaddr addr; diff --git a/subsys/net/lib/socks/socks.c b/subsys/net/lib/socks/socks.c index 3e384e47d70..bdff9946352 100644 --- a/subsys/net/lib/socks/socks.c +++ b/subsys/net/lib/socks/socks.c @@ -74,7 +74,7 @@ int socks5_client_tcp_connect(const struct sockaddr *proxy, mthd_req.r.ver = SOCKS5_PKT_MAGIC; /* We only support NOAUTH at the moment */ - mthd_req.r.nmethods = 1; + mthd_req.r.nmethods = 1U; mthd_req.methods[0] = SOCKS5_AUTH_METHOD_NOAUTH; /* size + 1 because just one method is supported */ diff --git a/subsys/settings/src/settings_fcb.c b/subsys/settings/src/settings_fcb.c index 46be409ae3a..755276215c0 100644 --- a/subsys/settings/src/settings_fcb.c +++ b/subsys/settings/src/settings_fcb.c @@ -156,7 +156,7 @@ static void settings_fcb_compress(struct settings_fcb *cf) loc1.fap = cf->cf_fcb.fap; loc1.loc.fe_sector = NULL; - loc1.loc.fe_elem_off = 0; + loc1.loc.fe_elem_off = 0U; while (fcb_getnext(&cf->cf_fcb, &loc1.loc) == 0) { if (loc1.loc.fe_sector != cf->cf_fcb.f_oldest) { diff --git a/subsys/shell/modules/kernel_service.c b/subsys/shell/modules/kernel_service.c index a3d271936a7..49f095b7ec6 100644 --- a/subsys/shell/modules/kernel_service.c +++ b/subsys/shell/modules/kernel_service.c @@ -63,7 +63,7 @@ static void shell_tdata_dump(const struct k_thread *thread, void *user_data) size); /* Calculate the real size reserved for the stack */ - pcnt = ((size - unused) * 100) / size; + pcnt = ((size - unused) * 100U) / size; tname = k_thread_name_get((struct k_thread *)thread); @@ -104,7 +104,7 @@ static void shell_stack_dump(const struct k_thread *thread, void *user_data) size); /* Calculate the real size reserved for the stack */ - pcnt = ((size - unused) * 100) / size; + pcnt = ((size - unused) * 100U) / size; shell_fprintf((const struct shell *)user_data, SHELL_NORMAL, "0x%08X %-10s (real size %u):\tunused %u\tusage %u / %u (%u %%)\n", diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index cf49983b1ff..e1d2e7ee9c2 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -109,7 +109,7 @@ static void tab_item_print(const struct shell *shell, const char *option, - shell_strlen(tab)) / longest_option; diff = longest_option - shell_strlen(option); - if (shell->ctx->vt100_ctx.printed_cmd++ % columns == 0) { + if (shell->ctx->vt100_ctx.printed_cmd++ % columns == 0U) { shell_internal_fprintf(shell, SHELL_OPTION, "\n%s%s", tab, option); } else { @@ -280,7 +280,7 @@ static bool tab_prepare(const struct shell *shell, u16_t compl_space = completion_space_get(shell); size_t search_argc; - if (compl_space == 0) { + if (compl_space == 0U) { return false; } @@ -837,7 +837,7 @@ static bool process_nl(const struct shell *shell, u8_t data) return false; } - if ((flag_last_nl_get(shell) == 0) || + if ((flag_last_nl_get(shell) == 0U) || (data == flag_last_nl_get(shell))) { flag_last_nl_set(shell, data); return true; @@ -1298,8 +1298,8 @@ void shell_process(const struct shell *shell) union shell_internal internal; - internal.value = 0; - internal.flags.processing = 1; + internal.value = 0U; + internal.flags.processing = 1U; (void)atomic_or((atomic_t *)&shell->ctx->internal.value, internal.value); @@ -1318,7 +1318,7 @@ void shell_process(const struct shell *shell) } internal.value = 0xFFFFFFFF; - internal.flags.processing = 0; + internal.flags.processing = 0U; (void)atomic_and((atomic_t *)&shell->ctx->internal.value, internal.value); } diff --git a/subsys/shell/shell_cmds.c b/subsys/shell/shell_cmds.c index 80a82c481f8..d13277aed2c 100644 --- a/subsys/shell/shell_cmds.c +++ b/subsys/shell/shell_cmds.c @@ -97,10 +97,10 @@ static int cursor_position_get(const struct shell *shell, u16_t *x, u16_t *y) /* Index start position in the buffer where 'y' * is stored. */ - buff_idx = 2; + buff_idx = 2U; while (shell->ctx->temp_buff[buff_idx] != ';') { - *y = *y * 10 + + *y = *y * 10U + (shell->ctx->temp_buff[buff_idx++] - '0'); if (buff_idx >= @@ -115,7 +115,7 @@ static int cursor_position_get(const struct shell *shell, u16_t *x, u16_t *y) while (shell->ctx->temp_buff[buff_idx] != '\0') { - *x = *x * 10 + + *x = *x * 10U + (shell->ctx->temp_buff[buff_idx++] - '0'); diff --git a/subsys/shell/shell_help.c b/subsys/shell/shell_help.c index fed9a0e173b..3cdbf5041c2 100644 --- a/subsys/shell/shell_help.c +++ b/subsys/shell/shell_help.c @@ -149,7 +149,7 @@ void shell_help_subcmd_print(const struct shell *shell) { const struct shell_static_entry *entry = NULL; struct shell_static_entry static_entry; - u16_t longest_syntax = 0; + u16_t longest_syntax = 0U; size_t cmd_idx = 0; /* Checking if there are any subcommands available. */ diff --git a/subsys/shell/shell_history.c b/subsys/shell/shell_history.c index ffad3cfc171..9c72b9444fc 100644 --- a/subsys/shell/shell_history.c +++ b/subsys/shell/shell_history.c @@ -19,14 +19,14 @@ bool shell_history_get(struct shell_history *history, bool up, sys_dnode_t *l_item; /* list item */ if (sys_dlist_is_empty(&history->list)) { - *len = 0; + *len = 0U; return false; } if (!up) { /* button down */ if (history->current == NULL) { /* Not in history mode. It is started by up button. */ - *len = 0; + *len = 0U; return false; } @@ -50,7 +50,7 @@ bool shell_history_get(struct shell_history *history, bool up, return true; } - *len = 0; + *len = 0U; return false; } diff --git a/subsys/shell/shell_ops.c b/subsys/shell/shell_ops.c index 75ef5a5777c..42cac67eb5a 100644 --- a/subsys/shell/shell_ops.c +++ b/subsys/shell/shell_ops.c @@ -31,14 +31,14 @@ void shell_op_cursor_horiz_move(const struct shell *shell, s32_t delta) static inline bool full_line_cmd(const struct shell *shell) { return ((shell->ctx->cmd_buff_len + shell_strlen(shell->ctx->prompt)) - % shell->ctx->vt100_ctx.cons.terminal_wid == 0); + % shell->ctx->vt100_ctx.cons.terminal_wid == 0U); } /* Function returns true if cursor is at beginning of an empty line. */ bool shell_cursor_in_empty_line(const struct shell *shell) { return ((shell->ctx->cmd_buff_pos + shell_strlen(shell->ctx->prompt)) - % shell->ctx->vt100_ctx.cons.terminal_wid == 0); + % shell->ctx->vt100_ctx.cons.terminal_wid == 0U); } void shell_op_cond_next_line(const struct shell *shell) @@ -101,12 +101,12 @@ void shell_op_cursor_move(const struct shell *shell, s16_t val) static u16_t shift_calc(const char *str, u16_t pos, u16_t len, s16_t sign) { bool found = false; - u16_t ret = 0; + u16_t ret = 0U; u16_t idx; while (1) { idx = pos + ret * sign; - if (((idx == 0) && (sign < 0)) || + if (((idx == 0U) && (sign < 0)) || ((idx == len) && (sign > 0))) { break; } @@ -298,7 +298,7 @@ void shell_op_char_delete(const struct shell *shell) u16_t diff = shell->ctx->cmd_buff_len - shell->ctx->cmd_buff_pos; char *str = &shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos]; - if (diff == 0) { + if (diff == 0U) { return; } diff --git a/subsys/shell/shell_uart.c b/subsys/shell/shell_uart.c index 996b7f9b381..f9dba456dd0 100644 --- a/subsys/shell/shell_uart.c +++ b/subsys/shell/shell_uart.c @@ -147,7 +147,7 @@ static void timer_handler(struct k_timer *timer) const struct shell_uart *sh_uart = k_timer_user_data_get(timer); while (uart_poll_in(sh_uart->ctrl_blk->dev, &c) == 0) { - if (ring_buf_put(sh_uart->rx_ringbuf, &c, 1) == 0) { + if (ring_buf_put(sh_uart->rx_ringbuf, &c, 1) == 0U) { /* ring buffer full. */ LOG_WRN("RX ring buffer full."); } diff --git a/subsys/shell/shell_utils.c b/subsys/shell/shell_utils.c index eb1a9bcefca..33414db1149 100644 --- a/subsys/shell/shell_utils.c +++ b/subsys/shell/shell_utils.c @@ -347,9 +347,9 @@ static void buffer_trim(char *buff, u16_t *buff_len) return; } - while (isspace((int) buff[*buff_len - 1])) { - *buff_len -= 1; - if (*buff_len == 0) { + while (isspace((int) buff[*buff_len - 1U])) { + *buff_len -= 1U; + if (*buff_len == 0U) { buff[0] = '\0'; return; } @@ -364,7 +364,7 @@ static void buffer_trim(char *buff, u16_t *buff_len) /* Removing counted whitespace characters. */ if (--i > 0) { - memmove(buff, buff + i, (*buff_len + 1) - i); /* +1 for '\0' */ + memmove(buff, buff + i, (*buff_len + 1U) - i); /* +1 for '\0' */ *buff_len = *buff_len - i; } } diff --git a/subsys/testsuite/coverage/coverage.c b/subsys/testsuite/coverage/coverage.c index 187963f8093..d8a232fb3fa 100644 --- a/subsys/testsuite/coverage/coverage.c +++ b/subsys/testsuite/coverage/coverage.c @@ -73,7 +73,7 @@ size_t calculate_buff_size(struct gcov_info *info) /* few Fixed values at the start version, stamp and magic number. */ u32_t size = sizeof(u32_t) * 3; - for (iter = 0; iter < info->n_functions; iter++) { + for (iter = 0U; iter < info->n_functions; iter++) { /* space for TAG_FUNCTION and FUNCTION_LENGTH * ident * lineno_checksum @@ -81,7 +81,7 @@ size_t calculate_buff_size(struct gcov_info *info) */ size += (sizeof(u32_t) * 5); - for (iter_1 = 0; iter_1 < GCOV_COUNTERS; iter_1++) { + for (iter_1 = 0U; iter_1 < GCOV_COUNTERS; iter_1++) { if (!info->merge[iter_1]) { continue; } @@ -89,7 +89,7 @@ size_t calculate_buff_size(struct gcov_info *info) /* for function counter and number of values */ size += (sizeof(u32_t) * 2); - for (iter_2 = 0; + for (iter_2 = 0U; iter_2 < info->functions[iter]->ctrs->num; iter_2++) { @@ -134,7 +134,7 @@ size_t populate_buffer(u8_t *buffer, struct gcov_info *info) &buffer_write_position, info->stamp); - for (iter_functions = 0; + for (iter_functions = 0U; iter_functions < info->n_functions; iter_functions++) { @@ -163,7 +163,7 @@ size_t populate_buffer(u8_t *buffer, struct gcov_info *info) counters_per_func = functions->ctrs; - for (iter_counts = 0; + for (iter_counts = 0U; iter_counts < GCOV_COUNTERS; iter_counts++) { @@ -177,9 +177,9 @@ size_t populate_buffer(u8_t *buffer, struct gcov_info *info) buff_write_u32(buffer, &buffer_write_position, - counters_per_func->num * 2); + counters_per_func->num * 2U); - for (iter_counter_values = 0; + for (iter_counter_values = 0U; iter_counter_values < counters_per_func->num; iter_counter_values++) { @@ -207,7 +207,7 @@ void dump_on_console(const char *filename, char *ptr, size_t len) /* Data dump */ - for (iter = 0; iter < len; iter++) { + for (iter = 0U; iter < len; iter++) { printk(" %02x", (u8_t)*ptr++); } } diff --git a/subsys/testsuite/include/test_utils.h b/subsys/testsuite/include/test_utils.h index dc4cce43087..98209e92550 100644 --- a/subsys/testsuite/include/test_utils.h +++ b/subsys/testsuite/include/test_utils.h @@ -40,7 +40,7 @@ static inline void show_str(const char *label, const u8_t *s, size_t len) u32_t i; TC_PRINT("%s = ", label); - for (i = 0; i < (u32_t)len; ++i) { + for (i = 0U; i < (u32_t)len; ++i) { TC_PRINT("%02x", s[i]); } TC_PRINT("\n"); diff --git a/subsys/usb/bos.c b/subsys/usb/bos.c index 4b49df67582..4ccd6614559 100644 --- a/subsys/usb/bos.c +++ b/subsys/usb/bos.c @@ -49,7 +49,7 @@ void usb_bos_register_cap(struct usb_bos_platform_descriptor *desc) /* Has effect only on first register */ hdr->wTotalLength = usb_bos_get_length(); - hdr->bNumDeviceCaps += 1; + hdr->bNumDeviceCaps += 1U; } int usb_handle_bos(struct usb_setup_packet *setup, diff --git a/subsys/usb/class/cdc_acm.c b/subsys/usb/class/cdc_acm.c index 47fe7fea2b4..5e425273238 100644 --- a/subsys/usb/class/cdc_acm.c +++ b/subsys/usb/class/cdc_acm.c @@ -795,8 +795,8 @@ static int cdc_acm_send_notification(struct device *dev, u16_t serial_state) notification.bmRequestType = 0xA1; notification.bNotificationType = 0x20; - notification.wValue = 0; - notification.wIndex = 0; + notification.wValue = 0U; + notification.wIndex = 0U; notification.wLength = sys_cpu_to_le16(sizeof(serial_state)); notification.data = sys_cpu_to_le16(serial_state); diff --git a/subsys/usb/class/hid/core.c b/subsys/usb/class/hid/core.c index f2c8165122f..9d50fa843c8 100644 --- a/subsys/usb/class/hid/core.c +++ b/subsys/usb/class/hid/core.c @@ -209,12 +209,12 @@ static int hid_on_set_idle(struct hid_device_info *dev_data, dev_data->idle_rate[report_id] = rate; - if (rate == 0) { + if (rate == 0U) { /* Clear idle */ bool clear = true; for (u16_t i = 1; i <= CONFIG_USB_HID_REPORTS; i++) { - if (dev_data->idle_rate[i] != 0) { + if (dev_data->idle_rate[i] != 0U) { /* Report with non-zero id has idle rate. */ clear = false; break; @@ -224,7 +224,7 @@ static int hid_on_set_idle(struct hid_device_info *dev_data, dev_data->idle_id_report = false; LOG_DBG("Non-zero report idle rate OFF."); - if (dev_data->idle_rate[0] == 0) { + if (dev_data->idle_rate[0] == 0U) { dev_data->idle_on = false; LOG_DBG("Idle rate OFF."); } @@ -233,7 +233,7 @@ static int hid_on_set_idle(struct hid_device_info *dev_data, /* Set idle */ dev_data->idle_on = true; LOG_DBG("Idle rate ON."); - if (report_id != 0) { + if (report_id != 0U) { /* Report with non-zero id has idle rate set now. */ dev_data->idle_id_report = true; LOG_DBG("Non-zero report idle rate ON."); @@ -302,8 +302,8 @@ void hid_clear_idle_ctx(struct hid_device_info *dev_data) dev_data->idle_on = false; dev_data->idle_id_report = false; for (u16_t i = 0; i <= CONFIG_USB_HID_REPORTS; i++) { - dev_data->sof_cnt[i] = 0; - dev_data->idle_rate[i] = 0; + dev_data->sof_cnt[i] = 0U; + dev_data->idle_rate[i] = 0U; } } @@ -314,11 +314,11 @@ void hid_sof_handler(struct hid_device_info *dev_data) dev_data->sof_cnt[i]++; } - u32_t diff = abs((dev_data->idle_rate[i] * 4) + u32_t diff = abs((dev_data->idle_rate[i] * 4U) - dev_data->sof_cnt[i]); - if (diff < (2 + (dev_data->idle_rate[i] / 10))) { - dev_data->sof_cnt[i] = 0; + if (diff < (2 + (dev_data->idle_rate[i] / 10U))) { + dev_data->sof_cnt[i] = 0U; if (dev_data->ops && dev_data->ops->on_idle) { dev_data->ops->on_idle(i); } diff --git a/subsys/usb/class/mass_storage.c b/subsys/usb/class/mass_storage.c index 54faa5f00d1..4f292bef17e 100644 --- a/subsys/usb/class/mass_storage.c +++ b/subsys/usb/class/mass_storage.c @@ -271,8 +271,8 @@ static int mass_storage_class_handle_req(struct usb_setup_packet *pSetup, static void testUnitReady(void) { - if (cbw.DataLength != 0) { - if ((cbw.Flags & 0x80) != 0) { + if (cbw.DataLength != 0U) { + if ((cbw.Flags & 0x80) != 0U) { LOG_WRN("Stall IN endpoint"); usb_ep_set_stall(mass_ep_data[MSD_IN_EP_IDX].ep_addr); } else { @@ -461,7 +461,7 @@ static bool infoTransfer(void) } if (cbw.DataLength != length) { - if ((cbw.Flags & 0x80) != 0) { + if ((cbw.Flags & 0x80) != 0U) { LOG_WRN("Stall IN endpoint"); usb_ep_set_stall(mass_ep_data[MSD_IN_EP_IDX].ep_addr); } else { @@ -499,7 +499,7 @@ static void CBWDecode(u8_t *buf, u16_t size) csw.Tag = cbw.Tag; csw.DataResidue = cbw.DataLength; - if ((cbw.CBLength < 1) || (cbw.CBLength > 16) || (cbw.LUN != 0)) { + if ((cbw.CBLength < 1) || (cbw.CBLength > 16) || (cbw.LUN != 0U)) { LOG_WRN("cbw.CBLength %d", cbw.CBLength); fail(); } else { diff --git a/subsys/usb/class/netusb/function_ecm.c b/subsys/usb/class/netusb/function_ecm.c index 5033af44aa5..eceb5386619 100644 --- a/subsys/usb/class/netusb/function_ecm.c +++ b/subsys/usb/class/netusb/function_ecm.c @@ -290,7 +290,7 @@ static void ecm_read_cb(u8_t ep, int size, void *priv) * a short packet containing a null byte. Handle by checking the IP * header length and dropping the extra byte. */ - if (rx_buf[size - 1] == 0) { /* last byte is null */ + if (rx_buf[size - 1] == 0U) { /* last byte is null */ if (ecm_eth_size(rx_buf, size) == (size - 1)) { /* last byte has been appended as delimiter, drop it */ size--; diff --git a/subsys/usb/class/netusb/function_rndis.c b/subsys/usb/class/netusb/function_rndis.c index e874356a079..c27bfd6e21f 100644 --- a/subsys/usb/class/netusb/function_rndis.c +++ b/subsys/usb/class/netusb/function_rndis.c @@ -349,7 +349,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status) /* We already use frame keeping with len, warn here about * receiving frame delimeter */ - if (len == 1 && !buffer[0]) { + if (len == 1U && !buffer[0]) { LOG_DBG("Got frame delimeter, skip"); return; } diff --git a/subsys/usb/class/usb_dfu.c b/subsys/usb/class/usb_dfu.c index 03e8a49dafd..f08fb7c75b1 100644 --- a/subsys/usb/class/usb_dfu.c +++ b/subsys/usb/class/usb_dfu.c @@ -462,7 +462,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup, dfu_data.state = dfuDNBUSY; dfu_data_worker.worker_state = dfuDNLOAD_IDLE; dfu_data_worker.worker_len = pSetup->wLength; - if (dfu_data_worker.worker_len == 0) { + if (dfu_data_worker.worker_len == 0U) { dfu_data.state = dfuMANIFEST_SYNC; k_poll_signal_raise(&dfu_signal, 0); } diff --git a/subsys/usb/usb_descriptor.c b/subsys/usb/usb_descriptor.c index a9995728662..5caf45843b8 100644 --- a/subsys/usb/usb_descriptor.c +++ b/subsys/usb/usb_descriptor.c @@ -191,7 +191,7 @@ int usb_get_str_descriptor_idx(void *ptr) struct usb_string_descriptor *str = ptr; int str_descr_idx = 0; - while (head->bLength != 0) { + while (head->bLength != 0U) { switch (head->bDescriptorType) { case USB_STRING_DESC: if (head == (struct usb_desc_header *)str) { @@ -341,7 +341,7 @@ static int usb_fix_descriptor(struct usb_desc_header *head) u8_t str_descr_idx = 0U; u32_t requested_ep = BIT(16) | BIT(0); - while (head->bLength != 0) { + while (head->bLength != 0U) { switch (head->bDescriptorType) { case USB_CONFIGURATION_DESC: cfg_descr = (struct usb_cfg_descriptor *)head; @@ -358,7 +358,7 @@ static int usb_fix_descriptor(struct usb_desc_header *head) break; } - if (if_descr->bInterfaceNumber == 0) { + if (if_descr->bInterfaceNumber == 0U) { cfg_data = usb_get_cfg_data(if_descr); if (!cfg_data) { LOG_ERR("There is no usb_cfg_data " @@ -414,7 +414,7 @@ static int usb_fix_descriptor(struct usb_desc_header *head) cfg_descr->bNumInterfaces = numof_ifaces; } - str_descr_idx += 1; + str_descr_idx += 1U; break; default: diff --git a/subsys/usb/usb_device.c b/subsys/usb/usb_device.c index 14e7e5e5da6..fca2b98245c 100644 --- a/subsys/usb/usb_device.c +++ b/subsys/usb/usb_device.c @@ -427,7 +427,7 @@ static bool usb_get_descriptor(u16_t type_index, u16_t lang_id, p = (u8_t *)usb_dev.descriptors; cur_index = 0; - while (p[DESC_bLength] != 0) { + while (p[DESC_bLength] != 0U) { if (p[DESC_bDescriptorType] == type) { if (cur_index == index) { found = true; @@ -479,7 +479,7 @@ static bool usb_set_configuration(u8_t config_index, u8_t alt_setting) u8_t cur_config = 0U; u8_t cur_alt_setting = 0U; - if (config_index == 0) { + if (config_index == 0U) { /* unconfigure device */ LOG_DBG("Device not configured - invalid configuration " "offset"); @@ -491,7 +491,7 @@ static bool usb_set_configuration(u8_t config_index, u8_t alt_setting) cur_config = 0xFF; cur_alt_setting = 0xFF; - while (p[DESC_bLength] != 0) { + while (p[DESC_bLength] != 0U) { switch (p[DESC_bDescriptorType]) { case DESC_CONFIGURATION: /* remember current configuration index */ @@ -555,7 +555,7 @@ static bool usb_set_interface(u8_t iface, u8_t alt_setting) LOG_DBG("iface %u alt_setting %u", iface, alt_setting); - while (p[DESC_bLength] != 0) { + while (p[DESC_bLength] != 0U) { switch (p[DESC_bDescriptorType]) { case DESC_INTERFACE: /* remember current alternate setting */ diff --git a/tests/benchmarks/sched/src/main.c b/tests/benchmarks/sched/src/main.c index 07fb2cf7a71..501aad81b54 100644 --- a/tests/benchmarks/sched/src/main.c +++ b/tests/benchmarks/sched/src/main.c @@ -110,8 +110,8 @@ void main(void) /* Let it start running and pend */ k_sleep(100); - u64_t tot = 0; - u32_t runs = 0; + u64_t tot = 0U; + u32_t runs = 0U; for (int i = 0; i < N_RUNS + N_SETTLE; i++) { stamp(UNPENDING); @@ -140,8 +140,8 @@ void main(void) tot += whole; avg = tot / (runs - 10); } else { - tot = 0; - avg = 0; + tot = 0U; + avg = 0U; } /* For reference, an unmodified HEAD on qemu_x86 with diff --git a/tests/benchmarks/sys_kernel/src/lifo.c b/tests/benchmarks/sys_kernel/src/lifo.c index f301657f7ac..448ea1c141e 100644 --- a/tests/benchmarks/sys_kernel/src/lifo.c +++ b/tests/benchmarks/sys_kernel/src/lifo.c @@ -231,7 +231,7 @@ int lifo_test(void) k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, lifo_thread1, NULL, (void *) number_of_loops, NULL, K_PRIO_COOP(3), 0, K_NO_WAIT); - for (i = 0; i < number_of_loops / 2; i++) { + for (i = 0; i < number_of_loops / 2U; i++) { int element[2]; int *pelement; diff --git a/tests/benchmarks/sys_kernel/src/mwfifo.c b/tests/benchmarks/sys_kernel/src/mwfifo.c index b9179b6c6da..8c354151e6a 100644 --- a/tests/benchmarks/sys_kernel/src/mwfifo.c +++ b/tests/benchmarks/sys_kernel/src/mwfifo.c @@ -226,12 +226,12 @@ int fifo_test(void) t = BENCH_START(); k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, fifo_thread1, - NULL, (void *) (number_of_loops / 2), NULL, + NULL, (void *) (number_of_loops / 2U), NULL, K_PRIO_COOP(3), 0, K_NO_WAIT); k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, fifo_thread1, - NULL, (void *) (number_of_loops / 2), NULL, + NULL, (void *) (number_of_loops / 2U), NULL, K_PRIO_COOP(3), 0, K_NO_WAIT); - for (i = 0; i < number_of_loops / 2; i++) { + for (i = 0; i < number_of_loops / 2U; i++) { int element[2]; int *pelement; diff --git a/tests/benchmarks/sys_kernel/src/stack.c b/tests/benchmarks/sys_kernel/src/stack.c index 7ac0861c770..9c12ca0a219 100644 --- a/tests/benchmarks/sys_kernel/src/stack.c +++ b/tests/benchmarks/sys_kernel/src/stack.c @@ -219,7 +219,7 @@ int stack_test(void) 0, (void *) number_of_loops, NULL, K_PRIO_COOP(3), 0, K_NO_WAIT); - for (i = 0; i < number_of_loops / 2; i++) { + for (i = 0; i < number_of_loops / 2U; i++) { u32_t data; data = 2 * i; diff --git a/tests/benchmarks/timing_info/src/yield_bench.c b/tests/benchmarks/timing_info/src/yield_bench.c index ed5c8bcc11d..254fc34e017 100644 --- a/tests/benchmarks/timing_info/src/yield_bench.c +++ b/tests/benchmarks/timing_info/src/yield_bench.c @@ -60,7 +60,7 @@ void yield_bench(void) k_sleep(1000); thread_sleep_end_time = ((u32_t)__common_var_swap_end_time); - u32_t yield_cycles = (thread_end_time - thread_start_time) / 2000; + u32_t yield_cycles = (thread_end_time - thread_start_time) / 2000U; u32_t sleep_cycles = thread_sleep_end_time - thread_sleep_start_time; PRINT_STATS("Thread Yield", yield_cycles, @@ -76,7 +76,7 @@ void thread_yield0_test(void *p1, void *p2, void *p3) k_sem_take(&yield_sem, 10); TIMING_INFO_PRE_READ(); thread_start_time = TIMING_INFO_OS_GET_TIME(); - while (count != 1000) { + while (count != 1000U) { count++; k_yield(); } diff --git a/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c b/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c index 68444dcfc57..77640a483e7 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c +++ b/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c @@ -103,7 +103,7 @@ static u8_t notify_func(struct bt_conn *conn, static int notify_count; if (!data) { printk("[UNSUBSCRIBED]\n"); - params->value_handle = 0; + params->value_handle = 0U; return BT_GATT_ITER_STOP; } @@ -284,7 +284,7 @@ static bool eir_found(struct bt_data *data, void *user_data) switch (data->type) { case BT_DATA_UUID16_SOME: case BT_DATA_UUID16_ALL: - if (data->data_len % sizeof(u16_t) != 0) { + if (data->data_len % sizeof(u16_t) != 0U) { FAIL("AD malformed\n"); return true; } diff --git a/tests/bluetooth/tester/src/bttester.h b/tests/bluetooth/tester/src/bttester.h index 534c65d84d4..9c75b66a49f 100644 --- a/tests/bluetooth/tester/src/bttester.h +++ b/tests/bluetooth/tester/src/bttester.h @@ -567,14 +567,14 @@ struct gatt_attr_value_changed_ev { static inline void tester_set_bit(u8_t *addr, unsigned int bit) { - u8_t *p = addr + (bit / 8); + u8_t *p = addr + (bit / 8U); *p |= BIT(bit % 8); } static inline u8_t tester_test_bit(const u8_t *addr, unsigned int bit) { - const u8_t *p = addr + (bit / 8); + const u8_t *p = addr + (bit / 8U); return *p & BIT(bit % 8); } diff --git a/tests/bluetooth/tester/src/gatt.c b/tests/bluetooth/tester/src/gatt.c index 511703d7d14..99d61902a5c 100644 --- a/tests/bluetooth/tester/src/gatt.c +++ b/tests/bluetooth/tester/src/gatt.c @@ -728,7 +728,7 @@ struct bt_gatt_indicate_params indicate_params; static void indicate_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr, u8_t err) { - if (err != 0) { + if (err != 0U) { LOG_ERR("Indication fail"); } else { LOG_DBG("Indication success"); @@ -1502,7 +1502,7 @@ static void write(u8_t *data, u16_t len) write_params.handle = sys_le16_to_cpu(cmd->handle); write_params.func = write_rsp; - write_params.offset = 0; + write_params.offset = 0U; write_params.data = cmd->data; write_params.length = sys_le16_to_cpu(cmd->data_length); @@ -1667,7 +1667,7 @@ static int disable_subscription(struct bt_conn *conn, u16_t ccc_handle) return -EBUSY; } - subscribe_params.ccc_handle = 0; + subscribe_params.ccc_handle = 0U; return 0; } diff --git a/tests/bluetooth/tester/src/l2cap.c b/tests/bluetooth/tester/src/l2cap.c index d6742e4abac..7aa6fb1e4a7 100644 --- a/tests/bluetooth/tester/src/l2cap.c +++ b/tests/bluetooth/tester/src/l2cap.c @@ -297,7 +297,7 @@ static void listen(u8_t *data, u16_t len) server->psm = cmd->psm; if (bt_l2cap_server_register(server) < 0) { - server->psm = 0; + server->psm = 0U; goto fail; } diff --git a/tests/boards/altera_max10/msgdma/src/dma.c b/tests/boards/altera_max10/msgdma/src/dma.c index 4343d933477..f2c4c983521 100644 --- a/tests/boards/altera_max10/msgdma/src/dma.c +++ b/tests/boards/altera_max10/msgdma/src/dma.c @@ -53,12 +53,12 @@ void test_msgdma(void) /* Init DMA config info */ dma_cfg.channel_direction = MEMORY_TO_MEMORY; - dma_cfg.source_data_size = 1; - dma_cfg.dest_data_size = 1; - dma_cfg.source_burst_length = 1; - dma_cfg.dest_burst_length = 1; + dma_cfg.source_data_size = 1U; + dma_cfg.dest_data_size = 1U; + dma_cfg.source_burst_length = 1U; + dma_cfg.dest_burst_length = 1U; dma_cfg.dma_callback = dma_user_callback; - dma_cfg.block_count = 1; + dma_cfg.block_count = 1U; dma_cfg.head_block = &dma_block_cfg; /* diff --git a/tests/boards/intel_s1000_crb/src/dma_test.c b/tests/boards/intel_s1000_crb/src/dma_test.c index 0a3211e9815..4be99fb03ff 100644 --- a/tests/boards/intel_s1000_crb/src/dma_test.c +++ b/tests/boards/intel_s1000_crb/src/dma_test.c @@ -146,14 +146,14 @@ static int test_task(u32_t chan_id, u32_t blen, u32_t block_count) } dma_cfg.channel_direction = MEMORY_TO_MEMORY; - dma_cfg.source_data_size = 1; - dma_cfg.dest_data_size = 1; + dma_cfg.source_data_size = 1U; + dma_cfg.dest_data_size = 1U; dma_cfg.source_burst_length = blen; dma_cfg.dest_burst_length = blen; dma_cfg.dma_callback = test_done; - dma_cfg.complete_callback_en = 0; - dma_cfg.error_callback_en = 1; - dma_cfg.block_count = 1; + dma_cfg.complete_callback_en = 0U; + dma_cfg.error_callback_en = 1U; + dma_cfg.block_count = 1U; dma_cfg.head_block = &dma_block_cfg; printk("Preparing DMA Controller: Chan_ID=%u, BURST_LEN=%u\n", @@ -177,7 +177,7 @@ static int test_task(u32_t chan_id, u32_t blen, u32_t block_count) printk("Starting the transfer\n"); - current_block_count = 0; + current_block_count = 0U; total_block_count = block_count; if (dma_start(dma_device, chan_id)) { diff --git a/tests/boards/intel_s1000_crb/src/spi_flash.c b/tests/boards/intel_s1000_crb/src/spi_flash.c index 1acffd8bd2e..944d21c3246 100644 --- a/tests/boards/intel_s1000_crb/src/spi_flash.c +++ b/tests/boards/intel_s1000_crb/src/spi_flash.c @@ -37,7 +37,7 @@ int flash_region_is_empty(u32_t off, void *dst, u32_t len) return -1; } - for (i = 0, u8dst = (uint8_t *)dst; i < len; i++) { + for (i = 0U, u8dst = (uint8_t *)dst; i < len; i++) { if (u8dst[i] != 0xFF) { flash_area_close(fap); return 0; diff --git a/tests/boards/native_posix/rtc/src/main.c b/tests/boards/native_posix/rtc/src/main.c index 5233104ac8a..924f84997ba 100644 --- a/tests/boards/native_posix/rtc/src/main.c +++ b/tests/boards/native_posix/rtc/src/main.c @@ -25,9 +25,9 @@ static char *us_time_to_str(char *dest, u64_t time) unsigned int second; unsigned int us; - hour = (time / 3600 / 1000000) % 24; - minute = (time / 60 / 1000000) % 60; - second = (time / 1000000) % 60; + hour = (time / 3600U / 1000000U) % 24; + minute = (time / 60U / 1000000U) % 60; + second = (time / 1000000U) % 60; us = time % 1000000; sprintf(dest, "%02u:%02u:%02u.%06u", hour, minute, second, us); diff --git a/tests/cmsis_rtos_v1/src/timer.c b/tests/cmsis_rtos_v1/src/timer.c index e2559ed7044..b562c2ff33d 100644 --- a/tests/cmsis_rtos_v1/src/timer.c +++ b/tests/cmsis_rtos_v1/src/timer.c @@ -64,8 +64,8 @@ void test_timer(void) * mode. Wait for 3 times the one-shot time to see * if it fires more than once. */ - osDelay(timerDelay*3 + 100); - zassert_true(num_oneshots_executed == 1, + osDelay(timerDelay*3U + 100); + zassert_true(num_oneshots_executed == 1U, "error setting up one-shot timer"); status = osTimerStop(id1); diff --git a/tests/cmsis_rtos_v2/src/event_flags.c b/tests/cmsis_rtos_v2/src/event_flags.c index 3b90254cfd6..4d5140962e1 100644 --- a/tests/cmsis_rtos_v2/src/event_flags.c +++ b/tests/cmsis_rtos_v2/src/event_flags.c @@ -104,7 +104,7 @@ void test_event_flags_no_wait_timeout(void) zassert_equal(flags & FLAG1, FLAG1, ""); flags = osEventFlagsGet(dummy_id); - zassert_true(flags == 0, + zassert_true(flags == 0U, "Invalid event Flags ID is unexpectedly working!"); /* Clear the Flag explicitly */ flags = osEventFlagsClear(evt_id, FLAG1); diff --git a/tests/cmsis_rtos_v2/src/kernel.c b/tests/cmsis_rtos_v2/src/kernel.c index 081dffb84b5..407f7770093 100644 --- a/tests/cmsis_rtos_v2/src/kernel.c +++ b/tests/cmsis_rtos_v2/src/kernel.c @@ -82,7 +82,7 @@ void delay_until(void *param) { tick = osKernelGetTickCount(); - tick += 50; + tick += 50U; status_val = osDelayUntil(tick); } diff --git a/tests/cmsis_rtos_v2/src/thread_apis.c b/tests/cmsis_rtos_v2/src/thread_apis.c index 51c61aa8ef4..10e10594363 100644 --- a/tests/cmsis_rtos_v2/src/thread_apis.c +++ b/tests/cmsis_rtos_v2/src/thread_apis.c @@ -67,7 +67,7 @@ static void thread1(void *argument) static void thread2(void *argument) { - u32_t i, num_threads, max_num_threads = 5; + u32_t i, num_threads, max_num_threads = 5U; osThreadId_t *thread_array; int *yield_check = (int *)argument; @@ -82,7 +82,7 @@ static void thread2(void *argument) zassert_equal(num_threads, 2, "Incorrect number of cmsis rtos v2 threads"); - for (i = 0; i < num_threads; i++) { + for (i = 0U; i < num_threads; i++) { zassert_true( osThreadGetStackSize(thread_array[i]) <= STACKSZ, "stack size allocated is not what is expected"); diff --git a/tests/cmsis_rtos_v2/src/timer.c b/tests/cmsis_rtos_v2/src/timer.c index 81e80bf89cd..7d91b9a4c4e 100644 --- a/tests/cmsis_rtos_v2/src/timer.c +++ b/tests/cmsis_rtos_v2/src/timer.c @@ -50,7 +50,7 @@ void test_timer(void) const char *name; /* Create one-shot timer */ - exec1 = 1; + exec1 = 1U; id1 = osTimerNew(Timer1_Callback, osTimerOnce, &exec1, &timer_attr); zassert_true(id1 != NULL, "error creating one-shot timer"); @@ -73,8 +73,8 @@ void test_timer(void) * mode. Wait for 3 times the one-shot time to see * if it fires more than once. */ - osDelay(timerDelay * 3 + 10); - zassert_true(num_oneshots_executed == 1, + osDelay(timerDelay * 3U + 10); + zassert_true(num_oneshots_executed == 1U, "error setting up one-shot timer"); status = osTimerStop(id1); @@ -84,7 +84,7 @@ void test_timer(void) zassert_true(status == osOK, "error deleting one-shot timer"); /* Create periodic timer */ - exec2 = 2; + exec2 = 2U; id2 = osTimerNew(Timer2_Callback, osTimerPeriodic, &exec2, NULL); zassert_true(id2 != NULL, "error creating periodic timer"); diff --git a/tests/crypto/tinycrypt/src/ccm_mode.c b/tests/crypto/tinycrypt/src/ccm_mode.c index c3a3a4b40f7..0b47bb1c680 100644 --- a/tests/crypto/tinycrypt/src/ccm_mode.c +++ b/tests/crypto/tinycrypt/src/ccm_mode.c @@ -108,7 +108,7 @@ u32_t do_test(const u8_t *key, dlen + mlen, &c); /**TESTPOINT: Check decryption*/ - if (result == 0) { + if (result == 0U) { show_str("\t\tExpected", data, dlen); show_str("\t\tComputed", decrypted, sizeof(decrypted)); @@ -398,7 +398,7 @@ void test_ccm_vector_7(void) hdr, 0, ciphertext, sizeof(data) + mlen, &c); - if (result == 0) { + if (result == 0U) { TC_ERROR("ccm_decrypt failed in %s.\n", __func__); show_str("\t\tExpected", data, sizeof(data)); show_str("\t\tComputed", decrypted, sizeof(decrypted)); @@ -455,7 +455,7 @@ void test_ccm_vector_8(void) hdr, sizeof(hdr), ciphertext, mlen, &c); /**TESTPOINT: Check CCM decryption*/ - if (result == 0) { + if (result == 0U) { show_str("\t\tExpected", data, sizeof(data)); show_str("\t\tComputed", decrypted, sizeof(decrypted)); diff --git a/tests/crypto/tinycrypt/src/ctr_prng.c b/tests/crypto/tinycrypt/src/ctr_prng.c index 564082079a7..bbf7e2db7ce 100644 --- a/tests/crypto/tinycrypt/src/ctr_prng.c +++ b/tests/crypto/tinycrypt/src/ctr_prng.c @@ -411,7 +411,7 @@ void test_ctr_prng_reseed(void) /* now, entropy and additional_input */ (void)memset(&ctx, 0x00, sizeof(ctx)); for (i = 0U; i < sizeof(extra_input); i++) { - extra_input[i] = i * 2; + extra_input[i] = i * 2U; } rc = tc_ctr_prng_reseed(&ctx, entropy, sizeof(entropy), diff --git a/tests/drivers/adc/adc_api/src/test_adc.c b/tests/drivers/adc/adc_api/src/test_adc.c index 4f8e4548746..8a81c269682 100644 --- a/tests/drivers/adc/adc_api/src/test_adc.c +++ b/tests/drivers/adc/adc_api/src/test_adc.c @@ -373,7 +373,7 @@ static enum adc_action repeated_samplings_callback( { ++m_samplings_done; TC_PRINT("%s: done %d\n", __func__, m_samplings_done); - if (m_samplings_done == 1) { + if (m_samplings_done == 1U) { #if defined(ADC_2ND_CHANNEL_ID) check_samples(2); #else diff --git a/tests/drivers/can/api/src/main.c b/tests/drivers/can/api/src/main.c index 40b69c5eb67..51263835a06 100644 --- a/tests/drivers/can/api/src/main.c +++ b/tests/drivers/can/api/src/main.c @@ -236,7 +236,7 @@ static void send_receive(const struct zcan_filter *filter, struct zcan_frame *ms struct device *can_dev; int ret, filter_id; struct zcan_frame msg_buffer; - u32_t mask = 0; + u32_t mask = 0U; can_dev = device_get_binding(DT_CAN_1_NAME); zassert_not_null(can_dev, "Device not not found"); diff --git a/tests/drivers/counter/counter_basic_api/src/test_counter.c b/tests/drivers/counter/counter_basic_api/src/test_counter.c index afcb156fefd..dc3f142460d 100644 --- a/tests/drivers/counter/counter_basic_api/src/test_counter.c +++ b/tests/drivers/counter/counter_basic_api/src/test_counter.c @@ -81,7 +81,7 @@ typedef void (*counter_test_func_t)(const char *dev_name); static void counter_setup_instance(const char *dev_name) { - alarm_cnt = 0; + alarm_cnt = 0U; } static void counter_tear_down_instance(const char *dev_name) @@ -123,7 +123,7 @@ void test_set_top_value_with_alarm_instance(const char *dev_name) u32_t ticks; u32_t tmp_top_cnt; - top_cnt = 0; + top_cnt = 0U; dev = device_get_binding(dev_name); ticks = counter_us_to_ticks(dev, COUNTER_PERIOD_US); @@ -143,7 +143,7 @@ void test_set_top_value_with_alarm_instance(const char *dev_name) k_busy_wait(5.2*COUNTER_PERIOD_US); tmp_top_cnt = top_cnt; /* to avoid passing volatile to the macro */ - zassert_true(tmp_top_cnt == 5, + zassert_true(tmp_top_cnt == 5U, "Unexpected number of turnarounds (%d) (dev: %s).\n", tmp_top_cnt, dev_name); } @@ -180,7 +180,7 @@ void test_single_shot_alarm_instance(const char *dev_name, bool set_top) alarm_cfg.callback = alarm_handler; alarm_cfg.user_data = &alarm_cfg; - alarm_cnt = 0; + alarm_cnt = 0U; if (counter_get_num_of_channels(dev) < 1U) { /* Counter does not support any alarm */ @@ -286,7 +286,7 @@ void test_multiple_alarms_instance(const char *dev_name) alarm_cfg2.callback = alarm_handler2; alarm_cfg2.user_data = &alarm_cfg2; - alarm_cnt = 0; + alarm_cnt = 0U; if (counter_get_num_of_channels(dev) < 2U) { /* Counter does not support two alarms */ diff --git a/tests/drivers/dma/chan_blen_transfer/src/test_dma.c b/tests/drivers/dma/chan_blen_transfer/src/test_dma.c index 45fb6a8b88e..accb656cef5 100644 --- a/tests/drivers/dma/chan_blen_transfer/src/test_dma.c +++ b/tests/drivers/dma/chan_blen_transfer/src/test_dma.c @@ -50,14 +50,14 @@ static int test_task(u32_t chan_id, u32_t blen) } dma_cfg.channel_direction = MEMORY_TO_MEMORY; - dma_cfg.source_data_size = 1; - dma_cfg.dest_data_size = 1; + dma_cfg.source_data_size = 1U; + dma_cfg.dest_data_size = 1U; dma_cfg.source_burst_length = blen; dma_cfg.dest_burst_length = blen; dma_cfg.dma_callback = test_done; - dma_cfg.complete_callback_en = 0; - dma_cfg.error_callback_en = 1; - dma_cfg.block_count = 1; + dma_cfg.complete_callback_en = 0U; + dma_cfg.error_callback_en = 1U; + dma_cfg.block_count = 1U; dma_cfg.head_block = &dma_block_cfg; TC_PRINT("Preparing DMA Controller: Chan_ID=%u, BURST_LEN=%u\n", diff --git a/tests/drivers/dma/loop_transfer/src/dma.c b/tests/drivers/dma/loop_transfer/src/dma.c index ca874059b33..b4230fae0e6 100644 --- a/tests/drivers/dma/loop_transfer/src/dma.c +++ b/tests/drivers/dma/loop_transfer/src/dma.c @@ -77,13 +77,13 @@ void main(void) } dma_cfg.channel_direction = MEMORY_TO_MEMORY; - dma_cfg.source_data_size = 1; - dma_cfg.dest_data_size = 1; - dma_cfg.source_burst_length = 1; - dma_cfg.dest_burst_length = 1; + dma_cfg.source_data_size = 1U; + dma_cfg.dest_data_size = 1U; + dma_cfg.source_burst_length = 1U; + dma_cfg.dest_burst_length = 1U; dma_cfg.callback_arg = dma; dma_cfg.dma_callback = dma_user_callback; - dma_cfg.block_count = 1; + dma_cfg.block_count = 1U; dma_cfg.head_block = &dma_block_cfg; chan_id = 0U; diff --git a/tests/drivers/gpio/gpio_basic_api/src/test_pin_rw.c b/tests/drivers/gpio/gpio_basic_api/src/test_pin_rw.c index d277030c3c6..f6b2b0ee91c 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/test_pin_rw.c +++ b/tests/drivers/gpio/gpio_basic_api/src/test_pin_rw.c @@ -31,7 +31,7 @@ void test_gpio_pin_read_write(void) int i = 0; while (i++ < 32) { - val_write = sys_rand32_get() / 3 % 2; + val_write = sys_rand32_get() / 3U % 2; zassert_true(gpio_pin_write(dev, PIN_OUT, val_write) == 0, "write data fail"); TC_PRINT("write: %" PRIu32 "\n", val_write); diff --git a/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c b/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c index a072955875a..b80a480d42d 100644 --- a/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c +++ b/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c @@ -180,7 +180,7 @@ static int i2c_virtual_transfer(struct device *dev, struct i2c_msg *msg, } /* Stop condition is required for the last message */ - if ((num_msgs == 1) && !(current->flags & I2C_MSG_STOP)) { + if ((num_msgs == 1U) && !(current->flags & I2C_MSG_STOP)) { ret = -EINVAL; break; } diff --git a/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c b/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c index 23292b0a1c0..1606c336656 100644 --- a/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c +++ b/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c @@ -43,8 +43,8 @@ void test_i2s_tx_transfer_configure_0(void) /* Configure */ - i2s_cfg.word_size = 16; - i2s_cfg.channels = 2; + i2s_cfg.word_size = 16U; + i2s_cfg.channels = 2U; i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_SLAVE; i2s_cfg.frame_clk_freq = FRAME_CLK_FREQ; @@ -69,8 +69,8 @@ void test_i2s_rx_transfer_configure_0(void) /* Configure */ - i2s_cfg.word_size = 16; - i2s_cfg.channels = 2; + i2s_cfg.word_size = 16U; + i2s_cfg.channels = 2U; i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_SLAVE; i2s_cfg.frame_clk_freq = FRAME_CLK_FREQ; diff --git a/tests/drivers/i2s/i2s_api/src/test_i2s_states.c b/tests/drivers/i2s/i2s_api/src/test_i2s_states.c index a0c0c5f81e6..8f4723395e1 100644 --- a/tests/drivers/i2s/i2s_api/src/test_i2s_states.c +++ b/tests/drivers/i2s/i2s_api/src/test_i2s_states.c @@ -45,8 +45,8 @@ void test_i2s_tx_transfer_configure_1(void) /* Configure */ - i2s_cfg.word_size = 16; - i2s_cfg.channels = 2; + i2s_cfg.word_size = 16U; + i2s_cfg.channels = 2U; i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_SLAVE; i2s_cfg.frame_clk_freq = FRAME_CLK_FREQ; @@ -71,8 +71,8 @@ void test_i2s_rx_transfer_configure_1(void) /* Configure */ - i2s_cfg.word_size = 16; - i2s_cfg.channels = 2; + i2s_cfg.word_size = 16U; + i2s_cfg.channels = 2U; i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_SLAVE; i2s_cfg.frame_clk_freq = FRAME_CLK_FREQ; @@ -103,7 +103,7 @@ void test_i2s_state_not_ready_neg(void) dev_i2s = device_get_binding(I2S_DEV_NAME); zassert_not_null(dev_i2s, "device " I2S_DEV_NAME " not found"); - i2s_cfg.frame_clk_freq = 0; + i2s_cfg.frame_clk_freq = 0U; i2s_cfg.mem_slab = &rx_1_mem_slab; ret = i2s_configure(dev_i2s, I2S_DIR_RX, &i2s_cfg); @@ -127,7 +127,7 @@ void test_i2s_state_not_ready_neg(void) ret = i2s_buf_read(dev_i2s, rx_buf, &rx_size); zassert_equal(ret, -EIO, NULL); - i2s_cfg.frame_clk_freq = 0; + i2s_cfg.frame_clk_freq = 0U; i2s_cfg.mem_slab = &tx_1_mem_slab; ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); @@ -167,11 +167,11 @@ void test_i2s_state_ready_neg(void) /* Configure RX stream changing its state to READY */ - i2s_cfg.word_size = 16; - i2s_cfg.channels = 2; + i2s_cfg.word_size = 16U; + i2s_cfg.channels = 2U; i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_SLAVE; - i2s_cfg.frame_clk_freq = 8000; + i2s_cfg.frame_clk_freq = 8000U; i2s_cfg.block_size = BLOCK_SIZE; i2s_cfg.mem_slab = &rx_1_mem_slab; i2s_cfg.timeout = TIMEOUT; diff --git a/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c b/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c index a249aee3205..2accb9b9791 100644 --- a/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c +++ b/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c @@ -92,8 +92,8 @@ void test_i2s_tx_transfer_configure(void) /* Configure */ - i2s_cfg.word_size = 16; - i2s_cfg.channels = 2; + i2s_cfg.word_size = 16U; + i2s_cfg.channels = 2U; i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_SLAVE; i2s_cfg.frame_clk_freq = FRAME_CLK_FREQ; @@ -118,8 +118,8 @@ void test_i2s_rx_transfer_configure(void) /* Configure */ - i2s_cfg.word_size = 16; - i2s_cfg.channels = 2; + i2s_cfg.word_size = 16U; + i2s_cfg.channels = 2U; i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_SLAVE; i2s_cfg.frame_clk_freq = FRAME_CLK_FREQ; diff --git a/tests/drivers/rtc/rtc_basic_api/src/test_rtc_alarm.c b/tests/drivers/rtc/rtc_basic_api/src/test_rtc_alarm.c index 3e995adc657..1683ca9ef05 100644 --- a/tests/drivers/rtc/rtc_basic_api/src/test_rtc_alarm.c +++ b/tests/drivers/rtc/rtc_basic_api/src/test_rtc_alarm.c @@ -54,8 +54,8 @@ static int test_alarm(void) return TC_FAIL; } - config.init_val = 0; - config.alarm_enable = 1; + config.init_val = 0U; + config.alarm_enable = 1U; config.alarm_val = RTC_ALARM_SECOND; config.cb_fn = rtc_alarm_callback; diff --git a/tests/drivers/spi/spi_loopback/src/spi.c b/tests/drivers/spi/spi_loopback/src/spi.c index 08eccf7ae93..1c50270d352 100644 --- a/tests/drivers/spi/spi_loopback/src/spi.c +++ b/tests/drivers/spi/spi_loopback/src/spi.c @@ -337,7 +337,7 @@ static void spi_async_call_cb(struct k_poll_event *async_evt, k_sem_give(caller_sem); /* Reinitializing for next call */ - async_evt->signal->signaled = 0; + async_evt->signal->signaled = 0U; async_evt->state = K_POLL_STATE_NOT_READY; } } diff --git a/tests/drivers/uart/uart_async_api/src/test_uart_async.c b/tests/drivers/uart/uart_async_api/src/test_uart_async.c index 64e5123f7ac..d991740b6b6 100644 --- a/tests/drivers/uart/uart_async_api/src/test_uart_async.c +++ b/tests/drivers/uart/uart_async_api/src/test_uart_async.c @@ -75,7 +75,7 @@ void test_single_read(void) u8_t chained_read_buf0[10]; u8_t chained_read_buf1[20]; u8_t chained_read_buf2[30]; -u8_t buf_num = 1; +u8_t buf_num = 1U; u8_t *read_ptr; void test_chained_read_callback(struct uart_event *evt, void *user_data) @@ -91,16 +91,16 @@ void test_chained_read_callback(struct uart_event *evt, void *user_data) k_sem_give(&rx_rdy); break; case UART_RX_BUF_REQUEST: - if (buf_num == 1) { + if (buf_num == 1U) { uart_rx_buf_rsp(uart_dev, chained_read_buf1, sizeof(chained_read_buf1)); - buf_num = 2; - } else if (buf_num == 2) { + buf_num = 2U; + } else if (buf_num == 2U) { uart_rx_buf_rsp(uart_dev, chained_read_buf2, sizeof(chained_read_buf2)); - buf_num = 0; + buf_num = 0U; } break; case UART_RX_DISABLED: diff --git a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c index 3ea9e986d88..2299fb4d15b 100644 --- a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c +++ b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c @@ -145,7 +145,7 @@ static int test_wdt_no_callback(void) m_cfg_wdt0.callback = NULL; m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC; - m_cfg_wdt0.window.max = 2000; + m_cfg_wdt0.window.max = 2000U; err = wdt_install_timeout(wdt, &m_cfg_wdt0); if (err < 0) { TC_PRINT("Watchdog install error\n"); @@ -191,7 +191,7 @@ static int test_wdt_callback_1(void) m_testvalue = 0U; m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC; m_cfg_wdt0.callback = wdt_int_cb0; - m_cfg_wdt0.window.max = 2000; + m_cfg_wdt0.window.max = 2000U; err = wdt_install_timeout(wdt, &m_cfg_wdt0); if (err < 0) { TC_PRINT("Watchdog install error\n"); @@ -241,7 +241,7 @@ static int test_wdt_callback_2(void) m_testvalue = 0U; m_cfg_wdt0.callback = wdt_int_cb0; m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC; - m_cfg_wdt0.window.max = 2000; + m_cfg_wdt0.window.max = 2000U; err = wdt_install_timeout(wdt, &m_cfg_wdt0); if (err < 0) { @@ -251,7 +251,7 @@ static int test_wdt_callback_2(void) m_cfg_wdt1.callback = wdt_int_cb1; m_cfg_wdt1.flags = WDT_FLAG_RESET_SOC; - m_cfg_wdt1.window.max = 2000; + m_cfg_wdt1.window.max = 2000U; err = wdt_install_timeout(wdt, &m_cfg_wdt1); if (err < 0) { TC_PRINT("Watchdog install error\n"); @@ -289,7 +289,7 @@ static int test_wdt_bad_window_max(void) m_cfg_wdt0.callback = NULL; m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC; - m_cfg_wdt0.window.max = 0; + m_cfg_wdt0.window.max = 0U; err = wdt_install_timeout(wdt, &m_cfg_wdt0); if (err == -EINVAL) { return TC_PASS; @@ -300,24 +300,24 @@ static int test_wdt_bad_window_max(void) void test_wdt(void) { - if ((m_testcase_index != 1) && (m_testcase_index != 2)) { + if ((m_testcase_index != 1U) && (m_testcase_index != 2U)) { zassert_true(test_wdt_no_callback() == TC_PASS, NULL); } - if (m_testcase_index == 1) { + if (m_testcase_index == 1U) { #if TEST_WDT_CALLBACK_1 zassert_true(test_wdt_callback_1() == TC_PASS, NULL); #else m_testcase_index++; #endif } - if (m_testcase_index == 2) { + if (m_testcase_index == 2U) { #if TEST_WDT_CALLBACK_2 zassert_true(test_wdt_callback_2() == TC_PASS, NULL); #else m_testcase_index++; #endif } - if (m_testcase_index == 3) { + if (m_testcase_index == 3U) { zassert_true(test_wdt_bad_window_max() == TC_PASS, NULL); m_testcase_index++; } diff --git a/tests/kernel/boot_page_table/src/boot_page_table.c b/tests/kernel/boot_page_table/src/boot_page_table.c index 8e2beb1e27c..f3302a455ff 100644 --- a/tests/kernel/boot_page_table/src/boot_page_table.c +++ b/tests/kernel/boot_page_table/src/boot_page_table.c @@ -47,7 +47,7 @@ static void starting_addr_range(u32_t start_addr_range) addr_range += 0x1000) { value = X86_MMU_GET_PTE(&z_x86_kernel_pdpt, addr_range); status &= check_param(value, REGION_PERM); - zassert_false((status == 0), "error at %d permissions %d\n", + zassert_false((status == 0U), "error at %d permissions %d\n", addr_range, REGION_PERM); } } @@ -63,7 +63,7 @@ static void before_start_addr_range(u32_t start_addr_range) value = X86_MMU_GET_PTE(&z_x86_kernel_pdpt, addr_range); status &= check_param_nonset_region(value, REGION_PERM); - zassert_false((status == 0), "error at %d permissions %d\n", + zassert_false((status == 0U), "error at %d permissions %d\n", addr_range, REGION_PERM); } } @@ -78,7 +78,7 @@ static void ending_start_addr_range(u32_t start_addr_range) addr_range += 0x1000) { value = X86_MMU_GET_PTE(&z_x86_kernel_pdpt, addr_range); status &= check_param_nonset_region(value, REGION_PERM); - zassert_false((status == 0), "error at %d permissions %d\n", + zassert_false((status == 0U), "error at %d permissions %d\n", addr_range, REGION_PERM); } } diff --git a/tests/kernel/common/src/intmath.c b/tests/kernel/common/src/intmath.c index 2ddb18087d4..b36f2722528 100644 --- a/tests/kernel/common/src/intmath.c +++ b/tests/kernel/common/src/intmath.c @@ -78,12 +78,12 @@ void test_intmath(void) a = 30000U; b = 5872U; num = a * b; - zassert_true((num == 176160000), "32-bit multiplication failed"); + zassert_true((num == 176160000U), "32-bit multiplication failed"); a = 234424432U; b = 98982U; num = a / b; - zassert_true((num == 2368), "32-bit division failed"); + zassert_true((num == 2368U), "32-bit division failed"); } /** * @} diff --git a/tests/kernel/early_sleep/src/main.c b/tests/kernel/early_sleep/src/main.c index ba4eeeb9a36..7874ef7aeb9 100644 --- a/tests/kernel/early_sleep/src/main.c +++ b/tests/kernel/early_sleep/src/main.c @@ -103,7 +103,8 @@ static void test_early_sleep(void) k_thread_priority_set(k_current_get(), 0); TC_PRINT("msec per tick: %lld.%03lld, ticks to sleep: %d\n", - __ticks_to_ms(1000) / 1000, __ticks_to_ms(1000) % 1000, + __ticks_to_ms(1000) / 1000U, + __ticks_to_ms(1000) % 1000, TEST_TICKS_TO_SLEEP); /* Create a lower priority thread */ diff --git a/tests/kernel/fp_sharing/src/main.c b/tests/kernel/fp_sharing/src/main.c index d4e721fa4a0..ea6ed9a0fd7 100644 --- a/tests/kernel/fp_sharing/src/main.c +++ b/tests/kernel/fp_sharing/src/main.c @@ -172,7 +172,7 @@ void load_store_low(void) * perform any floating point operations! */ - while ((z_tick_get_32() % 5) != 0) { + while ((z_tick_get_32() % 5) != 0U) { /* * Use a volatile variable to prevent compiler * optimizing out the spin loop. @@ -234,7 +234,7 @@ void load_store_low(void) * k_float_disable() API, and to also continue exercising * the (exception based) floating enabling mechanism. */ - if ((load_store_low_count % 1000) == 0) { + if ((load_store_low_count % 1000) == 0U) { k_float_disable(k_current_get()); } #elif defined(CONFIG_CPU_CORTEX_M4) @@ -325,7 +325,7 @@ void load_store_high(void) /* periodically issue progress report */ - if ((++load_store_high_count % 100) == 0) { + if ((++load_store_high_count % 100) == 0U) { PRINT_DATA("Load and store OK after %u (high) " "+ %u (low) tests\n", load_store_high_count, diff --git a/tests/kernel/fp_sharing/src/pi.c b/tests/kernel/fp_sharing/src/pi.c index 960b60cd783..65f07864b16 100644 --- a/tests/kernel/fp_sharing/src/pi.c +++ b/tests/kernel/fp_sharing/src/pi.c @@ -149,7 +149,7 @@ void calculate_pi_high(void) /* periodically issue progress report */ - if ((++calc_pi_high_count % 100) == 50) { + if ((++calc_pi_high_count % 100) == 50U) { PRINT_DATA("Pi calculation OK after %u (high) +" " %u (low) tests (computed %1.6f)\n", calc_pi_high_count, calc_pi_low_count, pi); diff --git a/tests/kernel/mem_protect/mem_protect/src/kobject.c b/tests/kernel/mem_protect/mem_protect/src/kobject.c index e7997aa64d0..c06a0b09970 100644 --- a/tests/kernel/mem_protect/mem_protect/src/kobject.c +++ b/tests/kernel/mem_protect/mem_protect/src/kobject.c @@ -129,7 +129,7 @@ void test_thread_without_kobject_permission(void *p1, void *p2, void *p3) void kobject_user_test4(void *p1, void *p2, void *p3) { /* should cause a fault */ - if ((u32_t)p1 == 1) { + if ((u32_t)p1 == 1U) { valid_fault = false; } else { valid_fault = true; diff --git a/tests/kernel/mem_protect/mem_protect/src/mem_domain.c b/tests/kernel/mem_protect/mem_protect/src/mem_domain.c index 933f623e707..0bec2058448 100644 --- a/tests/kernel/mem_protect/mem_protect/src/mem_domain.c +++ b/tests/kernel/mem_protect/mem_protect/src/mem_domain.c @@ -104,7 +104,7 @@ void mem_domain_for_user(void *tc_number, void *p2, void *p3) void mem_domain_test_1(void *tc_number, void *p2, void *p3) { - if ((u32_t)tc_number == 1) { + if ((u32_t)tc_number == 1U) { mem_domain_buf[0] = 10U; k_mem_domain_remove_thread(k_current_get()); k_mem_domain_add_thread(&mem_domain_mem_domain, diff --git a/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c b/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c index 526a3011861..fb435051070 100644 --- a/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c +++ b/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c @@ -51,7 +51,7 @@ static void tmslab_alloc_align(void *data) * TESTPOINT: To ensure that each memory block is similarly * aligned to this boundary */ - zassert_true((u32_t)block[i] % BLK_ALIGN == 0, NULL); + zassert_true((u32_t)block[i] % BLK_ALIGN == 0U, NULL); } for (int i = 0; i < BLK_NUM; i++) { k_mem_slab_free(pslab, &block[i]); diff --git a/tests/kernel/poll/src/test_poll.c b/tests/kernel/poll/src/test_poll.c index 653fe4d2c6a..8d2e10421a7 100644 --- a/tests/kernel/poll/src/test_poll.c +++ b/tests/kernel/poll/src/test_poll.c @@ -208,7 +208,7 @@ void test_poll_wait(void) wait_events[1].state = K_POLL_STATE_NOT_READY; wait_events[2].state = K_POLL_STATE_NOT_READY; wait_events[3].state = K_POLL_STATE_NOT_READY; - wait_signal.signaled = 0; + wait_signal.signaled = 0U; zassert_equal(k_poll(wait_events, ARRAY_SIZE(wait_events), K_SECONDS(1)), -EAGAIN, ""); @@ -262,7 +262,7 @@ void test_poll_wait(void) wait_events[0].state = K_POLL_STATE_NOT_READY; wait_events[1].state = K_POLL_STATE_NOT_READY; wait_events[2].state = K_POLL_STATE_NOT_READY; - wait_signal.signaled = 0; + wait_signal.signaled = 0U; k_thread_create(&poll_wait_helper_thread, poll_wait_helper_stack, K_THREAD_STACK_SIZEOF(poll_wait_helper_stack), @@ -329,7 +329,7 @@ void test_poll_wait(void) zassert_equal(wait_events[2].tag, TAG_2, ""); wait_events[2].state = K_POLL_STATE_NOT_READY; - wait_signal.signaled = 0; + wait_signal.signaled = 0U; } /* verify k_poll() that waits on object which gets cancellation */ diff --git a/tests/kernel/semaphore/semaphore/src/main.c b/tests/kernel/semaphore/semaphore/src/main.c index 1a6d8f0ad5b..f2f5736ea10 100644 --- a/tests/kernel/semaphore/semaphore/src/main.c +++ b/tests/kernel/semaphore/semaphore/src/main.c @@ -221,7 +221,7 @@ void test_sem_take_no_wait_fails(void) "k_sem_take returned when not possible"); signal_count = k_sem_count_get(&simple_sem); - zassert_true(signal_count == 0, + zassert_true(signal_count == 0U, "signal count missmatch Expected 0, got %d\n", signal_count); } @@ -376,15 +376,15 @@ void test_sem_take_multiple(void) k_sleep(K_MSEC(200)); /* check which threads completed. */ signal_count = k_sem_count_get(&high_prio_sem); - zassert_true(signal_count == 1, + zassert_true(signal_count == 1U, "Higher priority threads didn't execute"); signal_count = k_sem_count_get(&mid_prio_sem); - zassert_true(signal_count == 0, + zassert_true(signal_count == 0U, "Medium priority threads shouldn't have executed"); signal_count = k_sem_count_get(&low_prio_sem); - zassert_true(signal_count == 0, + zassert_true(signal_count == 0U, "low priority threads shouldn't have executed"); /* enable the Medium priority thread to run. */ @@ -392,15 +392,15 @@ void test_sem_take_multiple(void) k_sleep(K_MSEC(200)); /* check which threads completed. */ signal_count = k_sem_count_get(&high_prio_sem); - zassert_true(signal_count == 1, + zassert_true(signal_count == 1U, "Higher priority thread executed again"); signal_count = k_sem_count_get(&mid_prio_sem); - zassert_true(signal_count == 1, + zassert_true(signal_count == 1U, "Medium priority thread didn't get executed"); signal_count = k_sem_count_get(&low_prio_sem); - zassert_true(signal_count == 0, + zassert_true(signal_count == 0U, "low priority thread shouldn't have executed"); /* enable the low priority thread to run. */ @@ -408,15 +408,15 @@ void test_sem_take_multiple(void) k_sleep(K_MSEC(200)); /* check which threads completed. */ signal_count = k_sem_count_get(&high_prio_sem); - zassert_true(signal_count == 1, + zassert_true(signal_count == 1U, "Higher priority thread executed again"); signal_count = k_sem_count_get(&mid_prio_sem); - zassert_true(signal_count == 1, + zassert_true(signal_count == 1U, "Medium priority thread executed again"); signal_count = k_sem_count_get(&low_prio_sem); - zassert_true(signal_count == 1, + zassert_true(signal_count == 1U, "low priority thread didn't get executed"); } @@ -511,12 +511,12 @@ void test_sem_multiple_threads_wait(void) } signal_count = k_sem_count_get(&simple_sem); - zassert_true(signal_count == 0, + zassert_true(signal_count == 0U, "signal count missmatch Expected 0, got %d\n", signal_count); signal_count = k_sem_count_get(&multiple_thread_sem); - zassert_true(signal_count == 0, + zassert_true(signal_count == 0U, "signal count missmatch Expected 0, got %d\n", signal_count); diff --git a/tests/kernel/timer/timer_monotonic/src/main.c b/tests/kernel/timer/timer_monotonic/src/main.c index bf77aefddcb..c7f95dbde7e 100644 --- a/tests/kernel/timer/timer_monotonic/src/main.c +++ b/tests/kernel/timer/timer_monotonic/src/main.c @@ -19,7 +19,7 @@ int test_frequency(void) end = k_cycle_get_32(); delta = end - start; - pct = (u64_t)delta * 100 / sys_clock_hw_cycles_per_sec(); + pct = (u64_t)delta * 100U / sys_clock_hw_cycles_per_sec(); printk("delta: %u expected: %u %u%%\n", delta, sys_clock_hw_cycles_per_sec(), pct); diff --git a/tests/lib/c_lib/src/main.c b/tests/lib/c_lib/src/main.c index 6b5fa7570af..c679b837eb4 100644 --- a/tests/lib/c_lib/src/main.c +++ b/tests/lib/c_lib/src/main.c @@ -103,7 +103,7 @@ volatile u32_t unsigned_int = 0xffffff00; void test_stdint(void) { - zassert_true((unsigned_int + unsigned_byte + 1u == 0), NULL); + zassert_true((unsigned_int + unsigned_byte + 1u == 0U), NULL); } diff --git a/tests/lib/ringbuffer/src/main.c b/tests/lib/ringbuffer/src/main.c index 0cc8ef07270..3755a936077 100644 --- a/tests/lib/ringbuffer/src/main.c +++ b/tests/lib/ringbuffer/src/main.c @@ -294,7 +294,7 @@ void test_ringbuffer_alloc_put(void) allocated = ring_buf_put_claim(&ringbuf_raw, &data, 1); sum_allocated = allocated; - zassert_true(allocated == 1, NULL); + zassert_true(allocated == 1U, NULL); allocated = ring_buf_put_claim(&ringbuf_raw, &data, @@ -318,7 +318,7 @@ void test_ringbuffer_alloc_put(void) for (int i = 0; i < 10; i++) { allocated = ring_buf_put_claim(&ringbuf_raw, &data, 2); - if (allocated == 2) { + if (allocated == 2U) { data[0] = inputbuf[0]; data[1] = inputbuf[1]; } else { @@ -328,7 +328,7 @@ void test_ringbuffer_alloc_put(void) } allocated = ring_buf_put_claim(&ringbuf_raw, &data, 2); - if (allocated == 2) { + if (allocated == 2U) { data[0] = inputbuf[2]; data[1] = inputbuf[3]; } else { @@ -342,7 +342,7 @@ void test_ringbuffer_alloc_put(void) read_size = ring_buf_get(&ringbuf_raw, outputbuf, 4); - zassert_true(read_size == 4, NULL); + zassert_true(read_size == 4U, NULL); zassert_true(memcmp(outputbuf, inputbuf, 4) == 0, NULL); } @@ -359,7 +359,7 @@ void test_byte_put_free(void) /* Ring buffer is empty */ granted = ring_buf_get_claim(&ringbuf_raw, &data, RINGBUFFER_SIZE); - zassert_true(granted == 0, NULL); + zassert_true(granted == 0U, NULL); for (int i = 0; i < 10; i++) { ring_buf_put(&ringbuf_raw, indata, diff --git a/tests/net/6lo/src/main.c b/tests/net/6lo/src/main.c index 6131824a872..530ed40d539 100644 --- a/tests/net/6lo/src/main.c +++ b/tests/net/6lo/src/main.c @@ -316,10 +316,10 @@ static struct net_pkt *create_pkt(struct net_6lo_data *data) net_pkt_set_ip_hdr_len(pkt, NET_IPV6H_LEN); net_pkt_lladdr_src(pkt)->addr = src_mac; - net_pkt_lladdr_src(pkt)->len = 8; + net_pkt_lladdr_src(pkt)->len = 8U; net_pkt_lladdr_dst(pkt)->addr = dst_mac; - net_pkt_lladdr_dst(pkt)->len = 8; + net_pkt_lladdr_dst(pkt)->len = 8U; frag = net_pkt_get_frag(pkt, K_FOREVER); if (!frag) { diff --git a/tests/net/checksum_offload/src/main.c b/tests/net/checksum_offload/src/main.c index c9656eeee6b..1a0eedf42b6 100644 --- a/tests/net/checksum_offload/src/main.c +++ b/tests/net/checksum_offload/src/main.c @@ -441,7 +441,7 @@ static bool add_neighbor(struct net_if *iface, struct in6_addr *addr) llstorage.addr[4] = 0x05; llstorage.addr[5] = 0x06; - lladdr.len = 6; + lladdr.len = 6U; lladdr.addr = llstorage.addr; lladdr.type = NET_LINK_ETHERNET; diff --git a/tests/net/context/src/main.c b/tests/net/context/src/main.c index e80bf65f15b..6f1358eedec 100644 --- a/tests/net/context/src/main.c +++ b/tests/net/context/src/main.c @@ -724,7 +724,7 @@ static void net_ctx_recv_v6_timeout(void) tid = start_timeout_v6_thread(WAIT_TIME_LONG); k_sem_reset(&wait_data); - k_sem_take(&wait_data, WAIT_TIME_LONG * 2); + k_sem_take(&wait_data, WAIT_TIME_LONG * 2U); net_ctx_send_v6(); @@ -752,7 +752,7 @@ static void net_ctx_recv_v4_timeout(void) tid = start_timeout_v4_thread(WAIT_TIME_LONG); k_sem_reset(&wait_data); - k_sem_take(&wait_data, WAIT_TIME_LONG * 2); + k_sem_take(&wait_data, WAIT_TIME_LONG * 2U); net_ctx_send_v4(); diff --git a/tests/net/ethernet_mgmt/src/main.c b/tests/net/ethernet_mgmt/src/main.c index b2cdee8ec50..99a6846d5c4 100644 --- a/tests/net/ethernet_mgmt/src/main.c +++ b/tests/net/ethernet_mgmt/src/main.c @@ -515,7 +515,7 @@ static void test_change_qav_params(void) /* Starting with delta bandwidth */ params.qav_param.type = ETHERNET_QAV_PARAM_TYPE_DELTA_BANDWIDTH; - params.qav_param.delta_bandwidth = 10; + params.qav_param.delta_bandwidth = 10U; ret = net_mgmt(NET_REQUEST_ETHERNET_SET_QAV_PARAM, iface, ¶ms, sizeof(struct ethernet_req_params)); @@ -523,7 +523,7 @@ static void test_change_qav_params(void) zassert_equal(ret, 0, "could not set delta bandwidth"); /* Reset local value - read-back and verify it */ - params.qav_param.delta_bandwidth = 0; + params.qav_param.delta_bandwidth = 0U; ret = net_mgmt(NET_REQUEST_ETHERNET_GET_QAV_PARAM, iface, ¶ms, sizeof(struct ethernet_req_params)); @@ -534,7 +534,7 @@ static void test_change_qav_params(void) /* And them the idle slope */ params.qav_param.type = ETHERNET_QAV_PARAM_TYPE_IDLE_SLOPE; - params.qav_param.idle_slope = 10; + params.qav_param.idle_slope = 10U; ret = net_mgmt(NET_REQUEST_ETHERNET_SET_QAV_PARAM, iface, ¶ms, sizeof(struct ethernet_req_params)); @@ -542,7 +542,7 @@ static void test_change_qav_params(void) zassert_equal(ret, 0, "could not set idle slope"); /* Reset local value - read-back and verify it */ - params.qav_param.idle_slope = 0; + params.qav_param.idle_slope = 0U; ret = net_mgmt(NET_REQUEST_ETHERNET_GET_QAV_PARAM, iface, ¶ms, sizeof(struct ethernet_req_params)); @@ -573,7 +573,7 @@ static void test_change_qav_params(void) zassert_not_equal(ret, 0, "allowed to set invalid delta bandwidth"); - params.qav_param.delta_bandwidth = 101; + params.qav_param.delta_bandwidth = 101U; ret = net_mgmt(NET_REQUEST_ETHERNET_SET_QAV_PARAM, iface, ¶ms, sizeof(struct ethernet_req_params)); @@ -602,7 +602,7 @@ static void test_change_qav_params(void) /* Now try to set valid parameters to an invalid queue id */ params.qav_param.type = ETHERNET_QAV_PARAM_TYPE_DELTA_BANDWIDTH; params.qav_param.queue_id = available_priority_queues; - params.qav_param.delta_bandwidth = 10; + params.qav_param.delta_bandwidth = 10U; ret = net_mgmt(NET_REQUEST_ETHERNET_SET_QAV_PARAM, iface, ¶ms, sizeof(struct ethernet_req_params)); @@ -610,7 +610,7 @@ static void test_change_qav_params(void) zassert_not_equal(ret, 0, "should not be able to set delta bandwidth"); params.qav_param.type = ETHERNET_QAV_PARAM_TYPE_IDLE_SLOPE; - params.qav_param.idle_slope = 10; + params.qav_param.idle_slope = 10U; ret = net_mgmt(NET_REQUEST_ETHERNET_SET_QAV_PARAM, iface, ¶ms, sizeof(struct ethernet_req_params)); diff --git a/tests/net/ieee802154/crypto/src/ieee802154_crypto_test.c b/tests/net/ieee802154/crypto/src/ieee802154_crypto_test.c index cfc66a393bc..123436146b5 100644 --- a/tests/net/ieee802154/crypto/src/ieee802154_crypto_test.c +++ b/tests/net/ieee802154/crypto/src/ieee802154_crypto_test.c @@ -138,8 +138,8 @@ static bool ds_test(struct device *dev) dec.keylen = sizeof(key); /* Setup CCM parameters */ - enc.mode_params.ccm_info.nonce_len = 13; - dec.mode_params.ccm_info.nonce_len = 13; + enc.mode_params.ccm_info.nonce_len = 13U; + dec.mode_params.ccm_info.nonce_len = 13U; enc.flags = CAP_RAW_KEY | CAP_INPLACE_OPS | CAP_SYNC_OPS; dec.flags = CAP_RAW_KEY | CAP_INPLACE_OPS | CAP_SYNC_OPS; @@ -174,7 +174,7 @@ static bool ds_test(struct device *dev) apkt.ad = buf; apkt.ad_len = sizeof(auth_data); - enc.mode_params.ccm_info.tag_len = 8; + enc.mode_params.ccm_info.tag_len = 8U; pkt.ctx = &enc; ret = cipher_ccm_op(&enc, &apkt, auth_nonce); @@ -189,7 +189,7 @@ static bool ds_test(struct device *dev) goto enc; } - dec.mode_params.ccm_info.tag_len = 8; + dec.mode_params.ccm_info.tag_len = 8U; pkt.ctx = &dec; ret = cipher_ccm_op(&dec, &apkt, auth_nonce); @@ -213,7 +213,7 @@ enc: apkt.tag = NULL; /* No tag = no MIC, thus no auth */ - enc.mode_params.ccm_info.tag_len = 0; + enc.mode_params.ccm_info.tag_len = 0U; pkt.ctx = &enc; ret = cipher_ccm_op(&enc, &apkt, enc_dec_nonce); @@ -228,7 +228,7 @@ enc: goto both; } - dec.mode_params.ccm_info.tag_len = 0; + dec.mode_params.ccm_info.tag_len = 0U; pkt.ctx = &dec; ret = cipher_ccm_op(&dec, &apkt, enc_dec_nonce); @@ -256,7 +256,7 @@ both: apkt.ad_len = sizeof(both_op_data) - 1; apkt.tag = NULL; - enc.mode_params.ccm_info.tag_len = 8; + enc.mode_params.ccm_info.tag_len = 8U; pkt.ctx = &enc; ret = cipher_ccm_op(&enc, &apkt, both_op_nonce); @@ -272,7 +272,7 @@ both: } pkt.in_len = 1 + 8; - dec.mode_params.ccm_info.tag_len = 8; + dec.mode_params.ccm_info.tag_len = 8U; pkt.ctx = &dec; ret = cipher_ccm_op(&dec, &apkt, both_op_nonce); diff --git a/tests/net/ieee802154/fragment/src/main.c b/tests/net/ieee802154/fragment/src/main.c index 91ad83d0ed3..e21411e9f83 100644 --- a/tests/net/ieee802154/fragment/src/main.c +++ b/tests/net/ieee802154/fragment/src/main.c @@ -475,7 +475,7 @@ static bool test_fragment(struct net_fragment_data *data) } ieee802154_fragment_ctx_init(&ctx, pkt, hdr_diff, data->iphc); - frame_buf.len = 0; + frame_buf.len = 0U; buf = pkt->buffer; while (buf) { @@ -492,7 +492,7 @@ static bool test_fragment(struct net_fragment_data *data) net_pkt_frag_add(f_pkt, dfrag); - frame_buf.len = 0; + frame_buf.len = 0U; } net_pkt_unref(pkt); diff --git a/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c b/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c index 2fae043e530..5cefd657b19 100644 --- a/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c +++ b/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c @@ -100,8 +100,8 @@ static void fake_iface_init(struct net_if *iface) net_if_set_link_addr(iface, mac, 8, NET_LINK_IEEE802154); ctx->pan_id = 0xabcd; - ctx->channel = 26; - ctx->sequence = 62; + ctx->channel = 26U; + ctx->sequence = 62U; NET_INFO("FAKE ieee802154 iface initialized\n"); } diff --git a/tests/net/iface/src/main.c b/tests/net/iface/src/main.c index 58e1897d322..e465486dcf7 100644 --- a/tests/net/iface/src/main.c +++ b/tests/net/iface/src/main.c @@ -94,7 +94,7 @@ static u8_t *net_iface_get_mac(struct device *dev) } data->ll_addr.addr = data->mac_addr; - data->ll_addr.len = 6; + data->ll_addr.len = 6U; return data->mac_addr; } @@ -552,7 +552,7 @@ static void select_src_iface(void) net_ipaddr_copy(&ipv4.sin_addr, &dst_addr_2); ipv4.sin_family = AF_INET; - ipv4.sin_port = 0; + ipv4.sin_port = 0U; iface = net_if_select_src_iface((struct sockaddr *)&ipv4); zassert_equal_ptr(iface, iface1, "Invalid interface %p vs %p selected", @@ -560,7 +560,7 @@ static void select_src_iface(void) net_ipaddr_copy(&ipv6.sin6_addr, &dst_addr1); ipv6.sin6_family = AF_INET6; - ipv6.sin6_port = 0; + ipv6.sin6_port = 0U; iface = net_if_select_src_iface((struct sockaddr *)&ipv6); zassert_equal_ptr(iface, iface1, "Invalid interface %p vs %p selected", diff --git a/tests/net/ipv6/src/main.c b/tests/net/ipv6/src/main.c index ffff806dc45..85ec65d0aea 100644 --- a/tests/net/ipv6/src/main.c +++ b/tests/net/ipv6/src/main.c @@ -244,11 +244,11 @@ static int tester_send(struct device *dev, struct net_pkt *pkt) } if (icmp->type == NET_ICMPV6_NS) { - if (dad_time[0] == 0) { + if (dad_time[0] == 0U) { dad_time[0] = k_uptime_get_32(); - } else if (dad_time[1] == 0) { + } else if (dad_time[1] == 0U) { dad_time[1] = k_uptime_get_32(); - } else if (dad_time[2] == 0) { + } else if (dad_time[2] == 0U) { dad_time[2] = k_uptime_get_32(); } @@ -402,7 +402,7 @@ static void test_add_neighbor(void) llstorage.addr[4] = 0x05; llstorage.addr[5] = 0x06; - lladdr.len = 6; + lladdr.len = 6U; lladdr.addr = llstorage.addr; lladdr.type = NET_LINK_ETHERNET; @@ -431,11 +431,11 @@ static void test_add_max_neighbors(void) llstorage.addr[4] = 0x05; llstorage.addr[5] = 0x07; - lladdr.len = 6; + lladdr.len = 6U; lladdr.addr = llstorage.addr; lladdr.type = NET_LINK_ETHERNET; - for (i = 0; i < CONFIG_NET_IPV6_MAX_NEIGHBORS + 1; i++) { + for (i = 0U; i < CONFIG_NET_IPV6_MAX_NEIGHBORS + 1; i++) { llstorage.addr[5] += i; dst_addr.s6_addr[15] += i; nbr = net_ipv6_nbr_add(net_if_get_default(), &dst_addr, @@ -536,7 +536,7 @@ static void test_prefix_timeout(void) net_if_ipv6_prefix_set_lf(prefix, false); net_if_ipv6_prefix_set_timer(prefix, lifetime); - k_sleep((lifetime * 2) * MSEC_PER_SEC); + k_sleep((lifetime * 2U) * MSEC_PER_SEC); prefix = net_if_ipv6_prefix_lookup(net_if_get_default(), &addr, len); @@ -686,7 +686,7 @@ static void test_hbho_message_1(void) "Data receive for HBHO failed."); /* Verify IPv6 Ext hdr length */ - zassert_false(net_pkt_ipv6_ext_len(pkt) == 72, + zassert_false(net_pkt_ipv6_ext_len(pkt) == 72U, "IPv6 mismatch ext hdr length"); } @@ -746,7 +746,7 @@ static void test_hbho_message_2(void) "Data receive for HBHO failed."); /* Verify IPv6 Ext hdr length */ - zassert_false(net_pkt_ipv6_ext_len(pkt) == 104, + zassert_false(net_pkt_ipv6_ext_len(pkt) == 104U, "IPv6 mismatch ext hdr length"); } @@ -908,7 +908,7 @@ static void test_hbho_message_3(void) "Data receive for HBHO failed."); /* Verify IPv6 Ext hdr length */ - zassert_false(net_pkt_ipv6_ext_len(pkt) == 920, + zassert_false(net_pkt_ipv6_ext_len(pkt) == 920U, "IPv6 mismatch ext hdr length"); } @@ -1043,7 +1043,7 @@ static void test_dad_timeout(void) struct net_if_addr *ifaddr; - dad_time[0] = dad_time[1] = dad_time[2] = 0; + dad_time[0] = dad_time[1] = dad_time[2] = 0U; ifaddr = net_if_ipv6_addr_add(iface, &addr1, NET_ADDR_AUTOCONF, 0xffff); zassert_not_null(ifaddr, "Address 1 cannot be added"); @@ -1089,12 +1089,12 @@ static struct net_pkt *setup_ipv6_udp(struct net_if *iface, } NET_IPV6_HDR(pkt)->vtc = 0x60; - NET_IPV6_HDR(pkt)->tcflow = 0; - NET_IPV6_HDR(pkt)->flow = 0; + NET_IPV6_HDR(pkt)->tcflow = 0U; + NET_IPV6_HDR(pkt)->flow = 0U; NET_IPV6_HDR(pkt)->len = htons(NET_UDPH_LEN + strlen(payload)); NET_IPV6_HDR(pkt)->nexthdr = IPPROTO_UDP; - NET_IPV6_HDR(pkt)->hop_limit = 255; + NET_IPV6_HDR(pkt)->hop_limit = 255U; net_ipaddr_copy(&NET_IPV6_HDR(pkt)->src, local_addr); net_ipaddr_copy(&NET_IPV6_HDR(pkt)->dst, remote_addr); diff --git a/tests/net/ipv6_fragment/src/main.c b/tests/net/ipv6_fragment/src/main.c index 237b29c90d7..a367be8882a 100644 --- a/tests/net/ipv6_fragment/src/main.c +++ b/tests/net/ipv6_fragment/src/main.c @@ -951,7 +951,7 @@ static u8_t *net_iface_get_mac(struct device *dev) } data->ll_addr.addr = data->mac_addr; - data->ll_addr.len = 6; + data->ll_addr.len = 6U; return data->mac_addr; } @@ -1001,22 +1001,22 @@ small: ipv6_first_frag[4] = total_len / 256; ipv6_first_frag[5] = total_len - - ipv6_first_frag[4] * 256; + ipv6_first_frag[4] * 256U; if ((total_len / 256) != pkt->buffer->data[4]) { DBG("Invalid length, 1st byte\n"); return -EINVAL; } - if ((total_len - pkt->buffer->data[4] * 256) != + if ((total_len - pkt->buffer->data[4] * 256U) != pkt->buffer->data[5]) { DBG("Invalid length, 2nd byte\n"); return -EINVAL; } - offset = pkt->buffer->data[6 * 8 + 2] * 256 + + offset = pkt->buffer->data[6 * 8 + 2] * 256U + (pkt->buffer->data[6 * 8 + 3] & 0xfe); - if (offset != 0) { + if (offset != 0U) { DBG("Invalid offset %d\n", offset); return -EINVAL; } @@ -1052,20 +1052,20 @@ small: ipv6_second_frag[4] = total_len / 256; ipv6_second_frag[5] = total_len - - ipv6_second_frag[4] * 256; + ipv6_second_frag[4] * 256U; if ((total_len / 256) != pkt->buffer->data[4]) { DBG("Invalid length, 1st byte\n"); return -EINVAL; } - if ((total_len - pkt->buffer->data[4] * 256) != + if ((total_len - pkt->buffer->data[4] * 256U) != pkt->buffer->data[5]) { DBG("Invalid length, 2nd byte\n"); return -EINVAL; } - offset = pkt->buffer->data[6 * 8 + 2] * 256 + + offset = pkt->buffer->data[6 * 8 + 2] * 256U + (pkt->buffer->data[6 * 8 + 3] & 0xfe); if (offset != pkt_recv_data_len) { @@ -1075,7 +1075,7 @@ small: } /* Make sure the MORE flag is set correctly */ - if ((pkt->buffer->data[6 * 8 + 3] & 0x01) != 0) { + if ((pkt->buffer->data[6 * 8 + 3] & 0x01) != 0U) { DBG("Invalid MORE flag for second fragment\n"); return -EINVAL; } @@ -1140,13 +1140,13 @@ large: return -EINVAL; } - if ((frag_offset & 0xfff8) != 0) { + if ((frag_offset & 0xfff8) != 0U) { DBG("Invalid fragment offset %d\n", frag_offset & 0xfff8); return -EINVAL; } - if ((frag_offset & 0x0001) != 1) { + if ((frag_offset & 0x0001) != 1U) { DBG("Fragment More flag should be set\n"); return -EINVAL; } @@ -1180,13 +1180,13 @@ large: return -EINVAL; } - if ((frag_offset & 0xfff8) != 200) { + if ((frag_offset & 0xfff8) != 200U) { DBG("Invalid fragment offset %d\n", frag_offset & 0xfff8); return -EINVAL; } - if ((frag_offset & 0x0001) != 1) { + if ((frag_offset & 0x0001) != 1U) { DBG("Fragment More flag should be set\n"); return -EINVAL; } @@ -1220,13 +1220,13 @@ large: return -EINVAL; } - if ((frag_offset & 0xfff8) != 400) { + if ((frag_offset & 0xfff8) != 400U) { DBG("Invalid fragment offset %d\n", frag_offset & 0xfff8); return -EINVAL; } - if ((frag_offset & 0x0001) != 0) { + if ((frag_offset & 0x0001) != 0U) { DBG("Fragment More flag should be unset\n"); return -EINVAL; } diff --git a/tests/net/lib/coap/src/main.c b/tests/net/lib/coap/src/main.c index e2bfea0bff3..d05d4ab8e8c 100644 --- a/tests/net/lib/coap/src/main.c +++ b/tests/net/lib/coap/src/main.c @@ -186,7 +186,7 @@ static int test_parse_empty_pdu(void) code = coap_header_get_code(&cpkt); id = coap_header_get_id(&cpkt); - if (ver != 1) { + if (ver != 1U) { TC_PRINT("Invalid version for parsed packet\n"); goto done; } @@ -201,7 +201,7 @@ static int test_parse_empty_pdu(void) goto done; } - if (id != 0) { + if (id != 0U) { TC_PRINT("Packet id doesn't match reference\n"); goto done; } @@ -247,7 +247,7 @@ static int test_parse_empty_pdu_1(void) code = coap_header_get_code(&cpkt); id = coap_header_get_id(&cpkt); - if (ver != 1) { + if (ver != 1U) { TC_PRINT("Invalid version for parsed packet\n"); goto done; } @@ -262,7 +262,7 @@ static int test_parse_empty_pdu_1(void) goto done; } - if (id != 0) { + if (id != 0U) { TC_PRINT("Packet id doesn't match reference\n"); goto done; } @@ -312,7 +312,7 @@ static int test_parse_simple_pdu(void) code = coap_header_get_code(&cpkt); id = coap_header_get_id(&cpkt); - if (ver != 1) { + if (ver != 1U) { TC_PRINT("Invalid version for parsed packet\n"); goto done; } @@ -334,7 +334,7 @@ static int test_parse_simple_pdu(void) tkl = coap_header_get_token(&cpkt, (u8_t *)token); - if (tkl != 5) { + if (tkl != 5U) { TC_PRINT("Token length doesn't match reference\n"); goto done; } @@ -351,12 +351,12 @@ static int test_parse_simple_pdu(void) goto done; } - if (options[0].len != 1) { + if (options[0].len != 1U) { TC_PRINT("Option length doesn't match the reference\n"); goto done; } - if (((u8_t *)options[0].value)[0] != 0) { + if (((u8_t *)options[0].value)[0] != 0U) { TC_PRINT("Option value doesn't match the reference\n"); goto done; } @@ -1033,7 +1033,7 @@ static int test_block2_size(void) goto done; } - if (i != 0) { + if (i != 0U) { k_free(rsp.data); } diff --git a/tests/net/lib/dns_resolve/src/main.c b/tests/net/lib/dns_resolve/src/main.c index 8a4da265fc8..b42be10a76b 100644 --- a/tests/net/lib/dns_resolve/src/main.c +++ b/tests/net/lib/dns_resolve/src/main.c @@ -96,7 +96,7 @@ static u8_t *net_iface_get_mac(struct device *dev) } data->ll_addr.addr = data->mac_addr; - data->ll_addr.len = 6; + data->ll_addr.len = 6U; return data->mac_addr; } diff --git a/tests/net/lib/mqtt_packet/src/mqtt_packet.c b/tests/net/lib/mqtt_packet/src/mqtt_packet.c index d8aa2811a3e..d4ecaa48dc7 100644 --- a/tests/net/lib/mqtt_packet/src/mqtt_packet.c +++ b/tests/net/lib/mqtt_packet/src/mqtt_packet.c @@ -646,7 +646,7 @@ static void print_array(const u8_t *a, u16_t size) TC_PRINT("\n"); for (i = 0U; i < size; i++) { TC_PRINT("%x ", a[i]); - if ((i+1) % 8 == 0) { + if ((i+1) % 8 == 0U) { TC_PRINT("\n"); } } diff --git a/tests/net/lib/mqtt_publisher/src/test_mqtt_publish.c b/tests/net/lib/mqtt_publisher/src/test_mqtt_publish.c index bbaadeeaace..aa5b00a52b7 100644 --- a/tests/net/lib/mqtt_publisher/src/test_mqtt_publish.c +++ b/tests/net/lib/mqtt_publisher/src/test_mqtt_publish.c @@ -192,8 +192,8 @@ static int publish(enum mqtt_qos qos) param.message.payload.len = strlen(param.message.payload.data); param.message_id = sys_rand32_get(); - param.dup_flag = 0; - param.retain_flag = 0; + param.dup_flag = 0U; + param.retain_flag = 0U; return mqtt_publish(&client_ctx, ¶m); } diff --git a/tests/net/lib/mqtt_pubsub/src/test_mqtt_pubsub.c b/tests/net/lib/mqtt_pubsub/src/test_mqtt_pubsub.c index 3d2a02ba7b9..2ad781578b7 100644 --- a/tests/net/lib/mqtt_pubsub/src/test_mqtt_pubsub.c +++ b/tests/net/lib/mqtt_pubsub/src/test_mqtt_pubsub.c @@ -330,7 +330,7 @@ static int test_subscribe(void) topic.topic.size = strlen(topic.topic.utf8); topic.qos = MQTT_QOS_1_AT_LEAST_ONCE; sub.list = &topic; - sub.list_count = 1; + sub.list_count = 1U; sub.message_id = sys_rand32_get(); rc = mqtt_subscribe(&client_ctx, &sub); @@ -361,8 +361,8 @@ static int test_publish(enum mqtt_qos qos) param.message.payload.data = (u8_t *)payload; param.message.payload.len = payload_left; param.message_id = sys_rand32_get(); - param.dup_flag = 0; - param.retain_flag = 0; + param.dup_flag = 0U; + param.retain_flag = 0U; rc = mqtt_publish(&client_ctx, ¶m); if (rc != 0) { @@ -393,7 +393,7 @@ static int test_unsubscribe(void) topic.topic.utf8 = get_mqtt_topic(); topic.topic.size = strlen(topic.topic.utf8); unsub.list = &topic; - unsub.list_count = 1; + unsub.list_count = 1U; unsub.message_id = sys_rand32_get(); rc = mqtt_unsubscribe(&client_ctx, &unsub); diff --git a/tests/net/lib/mqtt_subscriber/src/test_mqtt_subscribe.c b/tests/net/lib/mqtt_subscriber/src/test_mqtt_subscribe.c index bce7d47df8a..b44645cf34a 100644 --- a/tests/net/lib/mqtt_subscriber/src/test_mqtt_subscribe.c +++ b/tests/net/lib/mqtt_subscriber/src/test_mqtt_subscribe.c @@ -249,7 +249,7 @@ static int test_subscribe(void) topic.topic.size = strlen(topic.topic.utf8); topic.qos = MQTT_QOS_1_AT_LEAST_ONCE; sub.list = &topic; - sub.list_count = 1; + sub.list_count = 1U; sub.message_id = sys_rand32_get(); rc = mqtt_subscribe(&client_ctx, &sub); @@ -272,7 +272,7 @@ static int test_unsubscribe(void) topic.topic.utf8 = get_mqtt_topic(); topic.topic.size = strlen(topic.topic.utf8); unsub.list = &topic; - unsub.list_count = 1; + unsub.list_count = 1U; unsub.message_id = sys_rand32_get(); rc = mqtt_unsubscribe(&client_ctx, &unsub); diff --git a/tests/net/mld/src/main.c b/tests/net/mld/src/main.c index 5539e18ca6e..f4ba03d16c4 100644 --- a/tests/net/mld/src/main.c +++ b/tests/net/mld/src/main.c @@ -450,7 +450,7 @@ static void verify_send_report(void) } /* This value should be longer that the one in net_if.c when DAD timeouts */ -#define DAD_TIMEOUT (MSEC_PER_SEC / 5) +#define DAD_TIMEOUT (MSEC_PER_SEC / 5U) static void test_allnodes(void) { diff --git a/tests/net/net_pkt/src/main.c b/tests/net/net_pkt/src/main.c index 586ec899d24..c39b35cd48c 100644 --- a/tests/net/net_pkt/src/main.c +++ b/tests/net/net_pkt/src/main.c @@ -25,7 +25,7 @@ static u8_t small_buffer[512]; static void fake_dev_iface_init(struct net_if *iface) { - if (mac_addr[2] == 0) { + if (mac_addr[2] == 0U) { /* 00-00-5E-00-53-xx Documentation RFC 7042 */ mac_addr[0] = 0x00; mac_addr[1] = 0x00; @@ -431,7 +431,7 @@ void test_net_pkt_advanced_basics(void) { u32_t *val = (u32_t *)net_pkt_cursor_get_pos(pkt); - *val = 0; + *val = 0U; /* etc... */ } diff --git a/tests/net/route/src/main.c b/tests/net/route/src/main.c index 5cbe4355e94..1dea94b8b64 100644 --- a/tests/net/route/src/main.c +++ b/tests/net/route/src/main.c @@ -112,7 +112,7 @@ static u8_t *net_route_get_mac(struct device *dev) } route->ll_addr.addr = route->mac_addr; - route->ll_addr.len = 6; + route->ll_addr.len = 6U; return route->mac_addr; } diff --git a/tests/net/socket/poll/src/main.c b/tests/net/socket/poll/src/main.c index bde0c0e5877..276fe493f50 100644 --- a/tests/net/socket/poll/src/main.c +++ b/tests/net/socket/poll/src/main.c @@ -73,7 +73,7 @@ void test_poll(void) tstamp = k_uptime_get_32(); res = poll(pollfds, ARRAY_SIZE(pollfds), 30); tstamp = k_uptime_get_32() - tstamp; - zassert_true(tstamp >= 30 && tstamp <= 30 + FUZZ, ""); + zassert_true(tstamp >= 30U && tstamp <= 30 + FUZZ, ""); zassert_equal(res, 0, ""); diff --git a/tests/net/socket/select/src/main.c b/tests/net/socket/select/src/main.c index ebd90bb2cb3..9670a039397 100644 --- a/tests/net/socket/select/src/main.c +++ b/tests/net/socket/select/src/main.c @@ -112,7 +112,7 @@ void test_select(void) tstamp = k_uptime_get_32(); res = select(s_sock + 1, &readfds, NULL, NULL, &tval); tstamp = k_uptime_get_32() - tstamp; - zassert_true(tstamp >= 30 && tstamp <= 30 + FUZZ, ""); + zassert_true(tstamp >= 30U && tstamp <= 30 + FUZZ, ""); zassert_equal(res, 0, ""); diff --git a/tests/net/tcp/src/main.c b/tests/net/tcp/src/main.c index e4f9aeb9322..0b0fb8c2b07 100644 --- a/tests/net/tcp/src/main.c +++ b/tests/net/tcp/src/main.c @@ -95,7 +95,7 @@ static void net_tcp_iface_init(struct net_if *iface) static u8_t mac_addr_1[6]; static u8_t mac_addr_2[6]; - if (mac_addr_1[0] == 0) { + if (mac_addr_1[0] == 0U) { /* 00-00-5E-00-53-xx Documentation RFC 7042 */ mac_addr_1[0] = 0x00; mac_addr_1[1] = 0x00; @@ -108,7 +108,7 @@ static void net_tcp_iface_init(struct net_if *iface) NET_LINK_ETHERNET); } - if (mac_addr_2[0] == 0) { + if (mac_addr_2[0] == 0U) { mac_addr_2[0] = 0x00; mac_addr_2[1] = 0x00; mac_addr_2[2] = 0x5E; @@ -1500,7 +1500,7 @@ static bool test_tcp_seq_validity(void) } tcp->send_ack = sys_get_be32(tcp_hdr->seq) - - get_recv_wnd(tcp) / 2; + get_recv_wnd(tcp) / 2U; if (!net_tcp_validate_seq(tcp, tcp_hdr)) { DBG("1) Sequence validation failed (send_ack %u vs seq %u)\n", tcp->send_ack, sys_get_be32(tcp_hdr->seq)); diff --git a/tests/net/traffic_class/src/main.c b/tests/net/traffic_class/src/main.c index b2655553cab..4515d1c5db4 100644 --- a/tests/net/traffic_class/src/main.c +++ b/tests/net/traffic_class/src/main.c @@ -351,7 +351,7 @@ static bool add_neighbor(struct net_if *iface, struct in6_addr *addr) llstorage.addr[4] = 0x05; llstorage.addr[5] = 0x06; - lladdr.len = 6; + lladdr.len = 6U; lladdr.addr = llstorage.addr; lladdr.type = NET_LINK_ETHERNET; diff --git a/tests/net/tx_timestamp/src/main.c b/tests/net/tx_timestamp/src/main.c index d0f0c711b7a..dae6d6847ed 100644 --- a/tests/net/tx_timestamp/src/main.c +++ b/tests/net/tx_timestamp/src/main.c @@ -409,7 +409,7 @@ static bool add_neighbor(struct net_if *iface, struct in6_addr *addr) llstorage.addr[4] = 0x05; llstorage.addr[5] = 0x06; - lladdr.len = 6; + lladdr.len = 6U; lladdr.addr = llstorage.addr; lladdr.type = NET_LINK_ETHERNET; diff --git a/tests/net/vlan/src/main.c b/tests/net/vlan/src/main.c index d69927b233b..e8af0e24c1f 100644 --- a/tests/net/vlan/src/main.c +++ b/tests/net/vlan/src/main.c @@ -218,7 +218,7 @@ static u8_t *net_iface_get_mac(struct device *dev) } data->ll_addr.addr = data->mac_addr; - data->ll_addr.len = 6; + data->ll_addr.len = 6U; return data->mac_addr; } @@ -693,7 +693,7 @@ static bool add_neighbor(struct net_if *iface, struct in6_addr *addr) llstorage.addr[4] = 0x05; llstorage.addr[5] = 0x06; - lladdr.len = 6; + lladdr.len = 6U; lladdr.addr = llstorage.addr; lladdr.type = NET_LINK_ETHERNET; diff --git a/tests/posix/common/src/clock.c b/tests/posix/common/src/clock.c index fddf2b62311..ceb4759d907 100644 --- a/tests/posix/common/src/clock.c +++ b/tests/posix/common/src/clock.c @@ -69,7 +69,7 @@ void test_posix_realtime(void) */ struct timespec nts; nts.tv_sec = 1514821501; - nts.tv_nsec = NSEC_PER_SEC / 2; + nts.tv_nsec = NSEC_PER_SEC / 2U; /* TESTPOINT: Pass invalid clock type */ zassert_equal(clock_settime(CLOCK_INVALID, &nts), -1, @@ -100,7 +100,7 @@ void test_posix_realtime(void) ((s64_t)rts.tv_nsec - (s64_t)nts.tv_nsec); /* Make the delta 10ths of a second. */ - delta /= (NSEC_PER_SEC / 1000); + delta /= (NSEC_PER_SEC / 1000U); zassert_true(delta > last_delta, "Clock moved backward"); s64_t error = delta - last_delta; diff --git a/tests/posix/common/src/posix_rwlock.c b/tests/posix/common/src/posix_rwlock.c index 0b4f9cc05bc..b244ba18cd7 100644 --- a/tests/posix/common/src/posix_rwlock.c +++ b/tests/posix/common/src/posix_rwlock.c @@ -38,7 +38,7 @@ static void *thread_top(void *p1) printk("Thread %d acquiring WR lock\n", (s32_t) p1); ret = pthread_rwlock_trywrlock(&rwlock); - if (ret != 0) { + if (ret != 0U) { zassert_false(pthread_rwlock_wrlock(&rwlock), "Failed to acquire WR lock"); } diff --git a/tests/subsys/can/frame/src/main.c b/tests/subsys/can/frame/src/main.c index c2ee2c21122..9ffbfd88e21 100644 --- a/tests/subsys/can/frame/src/main.c +++ b/tests/subsys/can/frame/src/main.c @@ -28,9 +28,9 @@ static void test_can_frame_to_zcan_frame(void) frame.can_dlc = sizeof(data); memcpy(frame.data, data, sizeof(frame.data)); - expected.rtr = 1; - expected.id_type = 1; - expected.std_id = 1234; + expected.rtr = 1U; + expected.id_type = 1U; + expected.std_id = 1234U; expected.dlc = sizeof(data); can_copy_frame_to_zframe(&frame, &msg); @@ -57,9 +57,9 @@ static void test_zcan_frame_to_can_frame(void) expected.can_dlc = sizeof(data); memcpy(expected.data, data, sizeof(expected.data)); - msg.rtr = 1; - msg.id_type = 1; - msg.std_id = 1234; + msg.rtr = 1U; + msg.id_type = 1U; + msg.std_id = 1234U; msg.dlc = sizeof(data); memcpy(msg.data, data, sizeof(data)); @@ -86,11 +86,11 @@ static void test_can_filter_to_zcan_filter(void) filter.can_id = BIT(31) | BIT(30) | 1234; filter.can_mask = BIT(31) | BIT(30) | 1234; - expected.rtr = 1; - expected.id_type = 1; - expected.std_id = 1234; - expected.rtr_mask = 1; - expected.std_id_mask = 1234; + expected.rtr = 1U; + expected.id_type = 1U; + expected.std_id = 1234U; + expected.rtr_mask = 1U; + expected.std_id_mask = 1234U; can_copy_filter_to_zfilter(&filter, &msg_filter); @@ -119,11 +119,11 @@ static void test_zcan_filter_to_can_filter(void) expected.can_id = BIT(31) | BIT(30) | 1234; expected.can_mask = BIT(31) | BIT(30) | 1234; - msg_filter.rtr = 1; - msg_filter.id_type = 1; - msg_filter.std_id = 1234; - msg_filter.rtr_mask = 1; - msg_filter.std_id_mask = 1234; + msg_filter.rtr = 1U; + msg_filter.id_type = 1U; + msg_filter.std_id = 1234U; + msg_filter.rtr_mask = 1U; + msg_filter.std_id_mask = 1234U; can_copy_zfilter_to_filter(&msg_filter, &filter); diff --git a/tests/subsys/fs/fcb/src/fcb_test_init.c b/tests/subsys/fs/fcb/src/fcb_test_init.c index 6142a7b3565..f72179f32f1 100644 --- a/tests/subsys/fs/fcb/src/fcb_test_init.c +++ b/tests/subsys/fs/fcb/src/fcb_test_init.c @@ -23,12 +23,12 @@ void fcb_test_init(void) rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb); zassert_true(rc == FCB_ERR_ARGS, "fcb_init call should fail"); - fcb->f_sector_cnt = 2; + fcb->f_sector_cnt = 2U; fcb->f_magic = 0x12345678; rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb); zassert_true(rc == FCB_ERR_MAGIC, "fcb_init call should fail"); - fcb->f_magic = 0; + fcb->f_magic = 0U; rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb); zassert_true(rc == 0, "fcb_init call failure"); } diff --git a/tests/subsys/fs/fcb/src/fcb_test_last_of_n.c b/tests/subsys/fs/fcb/src/fcb_test_last_of_n.c index 64496f8c0c2..e05894ff5d2 100644 --- a/tests/subsys/fs/fcb/src/fcb_test_last_of_n.c +++ b/tests/subsys/fs/fcb/src/fcb_test_last_of_n.c @@ -18,7 +18,7 @@ void fcb_test_last_of_n(void) u8_t i; fcb = &test_fcb; - fcb->f_scratch_cnt = 1; + fcb->f_scratch_cnt = 1U; /* No fcbs available */ rc = fcb_offset_last_n(fcb, 1, &loc); diff --git a/tests/subsys/fs/fcb/src/fcb_test_multiple_scratch.c b/tests/subsys/fs/fcb/src/fcb_test_multiple_scratch.c index 6722f5b04c4..2014d78f4f8 100644 --- a/tests/subsys/fs/fcb/src/fcb_test_multiple_scratch.c +++ b/tests/subsys/fs/fcb/src/fcb_test_multiple_scratch.c @@ -21,7 +21,7 @@ void fcb_test_multi_scratch(void) }; fcb = &test_fcb; - fcb->f_scratch_cnt = 1; + fcb->f_scratch_cnt = 1U; /* * Now fill up everything. We should be able to get 3 of the sectors diff --git a/tests/subsys/fs/fcb/src/fcb_test_reset.c b/tests/subsys/fs/fcb/src/fcb_test_reset.c index a6013677b31..a6e027c115a 100644 --- a/tests/subsys/fs/fcb/src/fcb_test_reset.c +++ b/tests/subsys/fs/fcb/src/fcb_test_reset.c @@ -59,7 +59,7 @@ void fcb_test_reset(void) * Pretend reset */ (void)memset(fcb, 0, sizeof(*fcb)); - fcb->f_sector_cnt = 2; + fcb->f_sector_cnt = 2U; fcb->f_sectors = test_fcb_sector; rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb); @@ -97,7 +97,7 @@ void fcb_test_reset(void) zassert_true(rc == 0, "fcb_append call failure"); (void)memset(fcb, 0, sizeof(*fcb)); - fcb->f_sector_cnt = 2; + fcb->f_sector_cnt = 2U; fcb->f_sectors = test_fcb_sector; rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb); diff --git a/tests/subsys/fs/nffs_fs_api/common/test_performance.c b/tests/subsys/fs/nffs_fs_api/common/test_performance.c index 5ec00f1b9b8..f15948aa313 100644 --- a/tests/subsys/fs/nffs_fs_api/common/test_performance.c +++ b/tests/subsys/fs/nffs_fs_api/common/test_performance.c @@ -63,7 +63,7 @@ void test_performance(void) delta = k_uptime_delta_32(&reftime); printk("Created %d files in %d.%03d seconds\n", TEST_NUM_FILES, - delta / 1000, delta % 1000); + delta / 1000U, delta % 1000); /* 2. Unlink files benchmark */ printk("2. Unlinking files...\n"); @@ -78,7 +78,7 @@ void test_performance(void) delta = k_uptime_delta_32(&reftime); printk("Unlinked %d files in %d.%03d seconds\n", TEST_NUM_FILES, - delta / 1000, delta % 1000); + delta / 1000U, delta % 1000); /* Format to start on clean flash */ rc = nffs_format_full(area_descs); @@ -101,7 +101,7 @@ void test_performance(void) zassert_equal(rc, 0, "cannot close file"); delta = k_uptime_delta_32(&reftime); - printk("Written %d bytes in %d.%03d seconds\n", i, delta / 1000, + printk("Written %d bytes in %d.%03d seconds\n", i, delta / 1000U, delta % 1000); /* 4. Read file benchmark */ @@ -120,7 +120,7 @@ void test_performance(void) zassert_equal(rc, 0, "cannot close file"); delta = k_uptime_delta_32(&reftime); - printk("Read %d bytes in %d.%03d seconds\n", i, delta / 1000, + printk("Read %d bytes in %d.%03d seconds\n", i, delta / 1000U, delta % 1000); /* Format to start on clean flash */ @@ -145,7 +145,7 @@ void test_performance(void) zassert_equal(rc, 0, "cannot close file"); delta = k_uptime_delta_32(&reftime); - printk("Written %d bytes in %d.%03d seconds\n", i, delta / 1000, + printk("Written %d bytes in %d.%03d seconds\n", i, delta / 1000U, delta % 1000); /* 6. Read file benchmark */ @@ -165,6 +165,6 @@ void test_performance(void) zassert_equal(rc, 0, "cannot close file"); delta = k_uptime_delta_32(&reftime); - printk("Read %d bytes in %d.%03d seconds\n", i, delta / 1000, + printk("Read %d bytes in %d.%03d seconds\n", i, delta / 1000U, delta % 1000); } diff --git a/tests/subsys/jwt/src/jwt-test-private.c b/tests/subsys/jwt/src/jwt-test-private.c index 9a42dbde8d0..7553704af52 100644 --- a/tests/subsys/jwt/src/jwt-test-private.c +++ b/tests/subsys/jwt/src/jwt-test-private.c @@ -109,4 +109,4 @@ unsigned char jwt_test_private_der[] = { 0x49, 0x04, 0x64, 0xb3, 0xad, 0xe5, 0x6e, 0xc9, 0x29, 0xdd, 0x84, 0x3c, 0x47, 0x41, 0x92, 0xb0 }; -unsigned int jwt_test_private_der_len = 1216; +unsigned int jwt_test_private_der_len = 1216U; diff --git a/tests/subsys/logging/log_msg/src/log_msg_test.c b/tests/subsys/logging/log_msg/src/log_msg_test.c index 2fb5d8d15b7..feba421b55f 100644 --- a/tests/subsys/logging/log_msg/src/log_msg_test.c +++ b/tests/subsys/logging/log_msg/src/log_msg_test.c @@ -88,47 +88,47 @@ void test_log_std_msg(void) /* allocation of 4 argument fits in 2 buffers */ msg = log_msg_create_n(my_string, args, 4); - zassert_equal((used_slabs + 2), + zassert_equal((used_slabs + 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs += 2; + used_slabs += 2U; log_msg_put(msg); - zassert_equal((used_slabs - 2), + zassert_equal((used_slabs - 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs -= 2; + used_slabs -= 2U; /* allocation of 5 argument fits in 2 buffers */ msg = log_msg_create_n(my_string, args, 5); - zassert_equal((used_slabs + 2), + zassert_equal((used_slabs + 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs += 2; + used_slabs += 2U; log_msg_put(msg); - zassert_equal((used_slabs - 2), + zassert_equal((used_slabs - 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs -= 2; + used_slabs -= 2U; /* allocation of 5 argument fits in 2 buffers */ msg = log_msg_create_n(my_string, args, 6); - zassert_equal((used_slabs + 2), + zassert_equal((used_slabs + 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs += 2; + used_slabs += 2U; log_msg_put(msg); - zassert_equal((used_slabs - 2), + zassert_equal((used_slabs - 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs -= 2; + used_slabs -= 2U; } void test_log_hexdump_msg(void) @@ -178,34 +178,34 @@ void test_log_hexdump_msg(void) msg = log_msg_hexdump_create("test", data, LOG_MSG_HEXDUMP_BYTES_SINGLE_CHUNK + 1); - zassert_equal((used_slabs + 2), + zassert_equal((used_slabs + 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs += 2; + used_slabs += 2U; log_msg_put(msg); - zassert_equal((used_slabs - 2), + zassert_equal((used_slabs - 2U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs -= 2; + used_slabs -= 2U; /* allocation of buffer that fits in 3 buffers */ msg = log_msg_hexdump_create("test", data, LOG_MSG_HEXDUMP_BYTES_SINGLE_CHUNK + HEXDUMP_BYTES_CONT_MSG + 1); - zassert_equal((used_slabs + 3), + zassert_equal((used_slabs + 3U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs += 3; + used_slabs += 3U; log_msg_put(msg); - zassert_equal((used_slabs - 3), + zassert_equal((used_slabs - 3U), k_mem_slab_num_used_get(&log_msg_pool), "Expected mem slab allocation."); - used_slabs -= 3; + used_slabs -= 3U; } void test_log_hexdump_data_get_single_chunk(void) diff --git a/tests/subsys/logging/log_output/src/log_output_test.c b/tests/subsys/logging/log_output/src/log_output_test.c index f3002a82ee3..ba998dabdb9 100644 --- a/tests/subsys/logging/log_output/src/log_output_test.c +++ b/tests/subsys/logging/log_output/src/log_output_test.c @@ -25,7 +25,7 @@ static u32_t mock_len; static void reset_mock_buffer(void) { - mock_len = 0; + mock_len = 0U; memset(mock_buffer, 0, sizeof(mock_buffer)); } diff --git a/tests/subsys/settings/fcb/src/settings_test_save_1_fcb.c b/tests/subsys/settings/fcb/src/settings_test_save_1_fcb.c index 50d51c3afe6..e788ab71823 100644 --- a/tests/subsys/settings/fcb/src/settings_test_save_1_fcb.c +++ b/tests/subsys/settings/fcb/src/settings_test_save_1_fcb.c @@ -36,9 +36,9 @@ void test_config_save_1_fcb(void) rc = settings_load(); zassert_true(rc == 0, "fcb redout error"); - zassert_true(val8 == 33, "bad value read"); + zassert_true(val8 == 33U, "bad value read"); - val8 = 15; + val8 = 15U; rc = settings_save(); zassert_true(rc == 0, "fcb write error"); } diff --git a/tests/subsys/settings/fcb/src/settings_test_save_2_fcb.c b/tests/subsys/settings/fcb/src/settings_test_save_2_fcb.c index 2909c295d6e..6923680f376 100644 --- a/tests/subsys/settings/fcb/src/settings_test_save_2_fcb.c +++ b/tests/subsys/settings/fcb/src/settings_test_save_2_fcb.c @@ -45,7 +45,7 @@ void test_config_save_2_fcb(void) (void)memset(val_string[0], 0, sizeof(val_string[0])); rc = settings_load(); zassert_true(rc == 0, "fcb read error"); - zassert_true(val8 == 42, "bad value read"); + zassert_true(val8 == 42U, "bad value read"); zassert_true(!strcmp(val_string[0], test_ref_value[0]), "bad value read"); test_export_block = 1; @@ -71,7 +71,7 @@ void test_config_save_2_fcb(void) zassert_true(!memcmp(val_string, test_ref_value, sizeof(val_string)), "bad value read"); - zassert_true(val8 == 42, "bad value read"); + zassert_true(val8 == 42U, "bad value read"); } c2_var_count = 0; } diff --git a/tests/subsys/settings/fcb/src/settings_test_save_one_fcb.c b/tests/subsys/settings/fcb/src/settings_test_save_one_fcb.c index fdabb6ddc16..a1505b978d4 100644 --- a/tests/subsys/settings/fcb/src/settings_test_save_one_fcb.c +++ b/tests/subsys/settings/fcb/src/settings_test_save_one_fcb.c @@ -41,12 +41,12 @@ void test_config_save_one_fcb(void) rc = settings_load(); zassert_true(rc == 0, "fcb read error"); - zassert_true(val8 == 42, "bad value read"); + zassert_true(val8 == 42U, "bad value read"); rc = test_config_save_one_byte_value("myfoo/mybar", 44); zassert_true(rc == 0, "fcb one item write error"); rc = settings_load(); zassert_true(rc == 0, "fcb read error"); - zassert_true(val8 == 44, "bad value read"); + zassert_true(val8 == 44U, "bad value read"); } diff --git a/tests/subsys/settings/fcb/src/settings_test_save_unaligned.c b/tests/subsys/settings/fcb/src/settings_test_save_unaligned.c index 9a8118504c9..2d99a279fb0 100644 --- a/tests/subsys/settings/fcb/src/settings_test_save_unaligned.c +++ b/tests/subsys/settings/fcb/src/settings_test_save_unaligned.c @@ -37,9 +37,9 @@ void test_config_save_fcb_unaligned(void) rc = settings_load(); zassert_true(rc == 0, "fcb redout error"); - zassert_true(val8_un == 33, "bad value read"); + zassert_true(val8_un == 33U, "bad value read"); - val8_un = 15; + val8_un = 15U; rc = settings_save(); zassert_true(rc == 0, "fcb write error"); } diff --git a/tests/subsys/settings/nffs/src/settings_test_compress_file.c b/tests/subsys/settings/nffs/src/settings_test_compress_file.c index 0c5d377a8c7..cfd1ef48b8a 100644 --- a/tests/subsys/settings/nffs/src/settings_test_compress_file.c +++ b/tests/subsys/settings/nffs/src/settings_test_compress_file.c @@ -74,7 +74,7 @@ void test_config_compress_file(void) rc = file_str_cmp(cf.cf_name, exp_content_1, sizeof(exp_content_1)-1); zassert_true(rc == 0, "bad value read"); - val16 = 257; + val16 = 257U; for (int i = 0; i < 20; i++) { val64 = i; rc = settings_save(); diff --git a/tests/subsys/settings/nffs/src/settings_test_multiple_in_file.c b/tests/subsys/settings/nffs/src/settings_test_multiple_in_file.c index 9b663b7e18e..de82c749cc2 100644 --- a/tests/subsys/settings/nffs/src/settings_test_multiple_in_file.c +++ b/tests/subsys/settings/nffs/src/settings_test_multiple_in_file.c @@ -39,7 +39,7 @@ void test_config_multiple_in_file(void) settings_load(); zassert_true(test_set_called, "the SET handler wasn't called"); - zassert_true(val8 == 14, + zassert_true(val8 == 14U, "SET handler: was called with wrong parameters"); rc = fsutil_write_file(TEST_CONFIG_DIR "/mfg", cf_mfg_test2, @@ -48,6 +48,6 @@ void test_config_multiple_in_file(void) settings_load(); zassert_true(test_set_called, "the SET handler wasn't called"); - zassert_true(val8 == 15, + zassert_true(val8 == 15U, "SET handler: was called with wrong parameters"); } diff --git a/tests/subsys/settings/nffs/src/settings_test_save_one_file.c b/tests/subsys/settings/nffs/src/settings_test_save_one_file.c index dd8be2a34c7..abad3fd156c 100644 --- a/tests/subsys/settings/nffs/src/settings_test_save_one_file.c +++ b/tests/subsys/settings/nffs/src/settings_test_save_one_file.c @@ -40,12 +40,12 @@ void test_config_save_one_file(void) rc = settings_load(); zassert_true(rc == 0, "fs redout error"); - zassert_true(val8 == 42, "bad value read"); + zassert_true(val8 == 42U, "bad value read"); rc = test_config_save_one_byte_value("myfoo/mybar", 44); zassert_true(rc == 0, "fs one item write error"); rc = settings_load(); zassert_true(rc == 0, "fs redout error"); - zassert_true(val8 == 44, "bad value read"); + zassert_true(val8 == 44U, "bad value read"); } diff --git a/tests/subsys/settings/nffs/src/settings_test_small_file.c b/tests/subsys/settings/nffs/src/settings_test_small_file.c index f47d04de05e..f754fe7f165 100644 --- a/tests/subsys/settings/nffs/src/settings_test_small_file.c +++ b/tests/subsys/settings/nffs/src/settings_test_small_file.c @@ -40,7 +40,7 @@ void test_config_small_file(void) settings_load(); zassert_true(test_set_called, "the SET handler wasn't called"); - zassert_true(val8 == 1, + zassert_true(val8 == 1U, "SET handler: was called with wrong parameters"); ctest_clear_call_state(); @@ -51,7 +51,7 @@ void test_config_small_file(void) settings_load(); zassert_true(test_set_called, "the SET handler wasn't called"); - zassert_true(val8 == 8, + zassert_true(val8 == 8U, "SET handler: was called with wrong parameters"); ctest_clear_call_state(); diff --git a/tests/subsys/settings/src/settings_enc.c b/tests/subsys/settings/src/settings_enc.c index f7b0bfb94ca..9f85d49e083 100644 --- a/tests/subsys/settings/src/settings_enc.c +++ b/tests/subsys/settings/src/settings_enc.c @@ -9,7 +9,7 @@ static char enc_buf[128]; static int enc_buf_cnt; -static u8_t test_rwbs = 1; +static u8_t test_rwbs = 1U; #define ENC_CTX_VAL 0x2018 static int write_handler(void *ctx, off_t off, char const *buf, size_t len) diff --git a/tests/subsys/settings/src/settings_test_getset_int.c b/tests/subsys/settings/src/settings_test_getset_int.c index 6a5697181a9..7d0d9f58602 100644 --- a/tests/subsys/settings/src/settings_test_getset_int.c +++ b/tests/subsys/settings/src/settings_test_getset_int.c @@ -14,7 +14,7 @@ void test_config_getset_int(void) int rc; u8_t small_value; - small_value = 42; + small_value = 42U; strcpy(name, "myfoo/mybar"); rc = settings_set_value(name, &small_value, sizeof(small_value)); zassert_true(rc == 0, "can not set key value"); diff --git a/tests/unit/bluetooth/at/src/main.c b/tests/unit/bluetooth/at/src/main.c index f8845f8cb69..595e97011dd 100644 --- a/tests/unit/bluetooth/at/src/main.c +++ b/tests/unit/bluetooth/at/src/main.c @@ -49,7 +49,7 @@ static void at_test1(void) struct net_buf *buf; int len; - at.buf_max_len = 140; + at.buf_max_len = 140U; at.buf = buffer; buf = net_buf_alloc(&at_pool, K_FOREVER);