Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup of various warnings from clangd #3682

Merged
merged 11 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CompileFlags:
Remove:
- -mword-relocations

Diagnostics:
ClangTidy:
FastCheckFilter: None

---

If:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ jobs:
python3 scripts/testing/units.py ${{steps.device.outputs.flipper}}

- name: 'Check GDB output'
if: failure()
if: failure() && steps.flashing.outcome == 'success'
run: |
./fbt gdb_trace_all SWD_TRANSPORT_SERIAL=2A0906016415303030303032 LIB_DEBUG=1 FIRMWARE_APP_SET=unit_tests FORCE=1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "../accessor_app.h"
#include "../accessor_view_manager.h"
#include "../accessor_event.h"
#include "callback_connector.h"
#include "accessor_scene_start.h"

void AccessorSceneStart::on_enter(AccessorApp* app) {
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/battery_test_app/views/battery_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
drain_current > HIGH_DRAIN_CURRENT_THRESHOLD ? "mA!" : "mA");
} else if(drain_current != 0) {
snprintf(header, 20, "...");
} else if(data->charging_voltage < 4.2) {
} else if(data->charging_voltage < 4.2f) {
// Non-default battery charging limit, mention it
snprintf(emote, sizeof(emote), "Charged!");
snprintf(header, sizeof(header), "Limited to");
Expand Down
2 changes: 0 additions & 2 deletions applications/debug/display_test/display_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "display_test.h"

#include <furi_hal.h>
#include <furi.h>

Expand Down
1 change: 0 additions & 1 deletion applications/debug/display_test/display_test.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ static void lfrfid_debug_view_tune_draw_callback(Canvas* canvas, void* _model) {
canvas_set_color(canvas, ColorBlack);

char buffer[TEMP_STR_LEN + 1];
double freq = ((float)SystemCoreClock / ((float)model->ARR + 1));
double duty = ((float)model->CCR + 1) / ((float)model->ARR + 1) * 100.0f;
double freq = ((double)SystemCoreClock / (model->ARR + 1));
double duty = (double)((model->CCR + 1) * 100) / (model->ARR + 1);
snprintf(
buffer,
TEMP_STR_LEN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../subghz_test_app_i.h"
#include "../subghz_test_app_i.h" // IWYU pragma: keep

// Generate scene on_enter handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
Expand Down
2 changes: 0 additions & 2 deletions applications/debug/subghz_test/subghz_test_app_i.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "subghz_test_app_i.h"

#include <furi.h>

#define TAG "SubGhzTest"
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "subghz_test_carrier.h"
#include "../subghz_test_app_i.h"
#include "../helpers/subghz_test_frequency.h"
#include <lib/subghz/devices/cc1101_configs.h>

Expand Down Expand Up @@ -74,7 +73,7 @@ void subghz_test_carrier_draw(Canvas* canvas, SubGhzTestCarrierModel* model) {
sizeof(buffer),
"RSSI: %ld.%ld dBm",
(int32_t)(model->rssi),
(int32_t)fabs(model->rssi * 10) % 10);
(int32_t)fabsf(model->rssi * 10.f) % 10);
canvas_draw_str(canvas, 0, 42, buffer);
} else {
canvas_draw_str(canvas, 0, 42, "TX");
Expand Down
3 changes: 1 addition & 2 deletions applications/debug/subghz_test/views/subghz_test_packet.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "subghz_test_packet.h"
#include "../subghz_test_app_i.h"
#include "../helpers/subghz_test_frequency.h"
#include <lib/subghz/devices/cc1101_configs.h>

Expand Down Expand Up @@ -123,7 +122,7 @@ static void subghz_test_packet_draw(Canvas* canvas, SubGhzTestPacketModel* model
sizeof(buffer),
"RSSI: %ld.%ld dBm",
(int32_t)(model->rssi),
(int32_t)fabs(model->rssi * 10) % 10);
(int32_t)fabsf(model->rssi * 10.0f) % 10);
canvas_draw_str(canvas, 0, 53, buffer);
} else {
canvas_draw_str(canvas, 0, 53, "TX");
Expand Down
2 changes: 0 additions & 2 deletions applications/debug/subghz_test/views/subghz_test_static.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "subghz_test_static.h"
#include "../subghz_test_app_i.h"
#include "../helpers/subghz_test_frequency.h"
#include <lib/subghz/devices/cc1101_configs.h>

#include <math.h>
#include <furi.h>
#include <furi_hal.h>
#include <input/input.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <furi.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep
#include <bit_lib/bit_lib.h>

MU_TEST(test_bit_lib_increment_index) {
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/unit_tests/tests/bt/bt_test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <furi.h>
#include <furi_hal.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#include <bt/bt_service/bt_keys_storage.h>
#include <storage/storage.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#include <toolbox/compress.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <furi.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#include <datetime/datetime.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <dialogs/dialogs.h>

#include "../test.h"
#include "../test.h" // IWYU pragma: keep

MU_TEST(test_dialog_file_browser_set_basic_options_should_init_all_fields) {
mu_assert(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../test.h"
#include "../test.h" // IWYU pragma: keep
#include <furi.h>
#include <m-dict.h>
#include <toolbox/dir_walk.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#include <furi.h>
#include <furi_hal_random.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <flipper_format/flipper_format.h>
#include <flipper_format/flipper_format_i.h>
#include <toolbox/stream/stream.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#define TEST_DIR TEST_DIR_NAME "/"
#define TEST_DIR_NAME EXT_PATH("unit_tests_tmp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <flipper_format/flipper_format_i.h>
#include <toolbox/stream/stream.h>
#include <storage/storage.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

static const char* test_filetype = "Flipper Format test";
static const uint32_t test_version = 666;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <float.h>
#include <float_tools.h>

#include "../test.h"
#include "../test.h" // IWYU pragma: keep

MU_TEST(float_tools_equal_test) {
mu_check(float_is_equal(FLT_MAX, FLT_MAX));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../test.h"
#include "../test.h" // IWYU pragma: keep
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <furi.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

const uint32_t context_value = 0xdeadbeef;
const uint32_t notify_value_0 = 0x12345678;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include <stdio.h>
#include <string.h>
#include <furi.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#define TEST_RECORD_NAME "test/holding"

Expand Down
3 changes: 1 addition & 2 deletions applications/debug/unit_tests/tests/furi/furi_test.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <furi.h>
#include <furi_hal.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

// v2 tests
void test_furi_create_open(void);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "furi_hal_rtc.h"
#include <stdint.h>
#include <stdio.h>
#include <furi.h>
#include <furi_hal.h>
#include <lp5562_reg.h>
#include "../test.h"
#include <stdlib.h>
#include "../test.h" // IWYU pragma: keep

#define DATA_SIZE 4
#define EEPROM_ADDRESS 0b10101000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <furi.h>
#include <furi_hal.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

static const uint8_t key_ctr_1[32] = {
0x77, 0x6B, 0xEF, 0xF2, 0x85, 0x1D, 0xB0, 0x6F, 0x4C, 0x8A, 0x05, 0x42, 0xC8, 0x69, 0x6F, 0x6C,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <furi.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

static void test_setup(void) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <flipper_format.h>
#include <infrared.h>
#include <common/infrared_common_i.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#define IR_TEST_FILES_DIR EXT_PATH("unit_tests/infrared/")
#define IR_TEST_FILE_PREFIX "test_"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <furi.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep
#include <toolbox/protocols/protocol_dict.h>
#include <lfrfid/protocols/lfrfid_protocols.h>
#include <toolbox/pulse_protocols/pulse_glue.h>
Expand Down
4 changes: 2 additions & 2 deletions applications/debug/unit_tests/tests/manifest/manifest.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <furi.c>
#include "../test.h"
#include <furi.h>
#include "../test.h" // IWYU pragma: keep
#include <update_util/resources/manifest.h>

#define TAG "Manifest"
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/unit_tests/tests/nfc/nfc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <toolbox/keys_dict.h>
#include <nfc/nfc.h>

#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#define TAG "NfcTest"

Expand Down
23 changes: 12 additions & 11 deletions applications/debug/unit_tests/tests/power/power_test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <furi.h>
#include <furi_hal.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

static void power_test_deinit(void) {
// Try to reset to default charge voltage limit
Expand All @@ -13,46 +13,47 @@ MU_TEST(test_power_charge_voltage_limit_exact) {
//
// This test may need adapted if other charge controllers are used in the future.
for(uint16_t charge_mv = 3840; charge_mv <= 4208; charge_mv += 16) {
float charge_volt = (float)charge_mv / 1000.0f;
float charge_volt = (float)charge_mv / 1000;
furi_hal_power_set_battery_charge_voltage_limit(charge_volt);
mu_assert_double_eq(charge_volt, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(
(double)charge_volt, (double)furi_hal_power_get_battery_charge_voltage_limit());
}
}

MU_TEST(test_power_charge_voltage_limit_floating_imprecision) {
// 4.016f should act as 4.016 V, even with floating point imprecision
furi_hal_power_set_battery_charge_voltage_limit(4.016f);
mu_assert_double_eq(4.016f, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(4.016, (double)furi_hal_power_get_battery_charge_voltage_limit());
}

MU_TEST(test_power_charge_voltage_limit_inexact) {
// Charge voltage limits that are not power of 16mV get truncated down
furi_hal_power_set_battery_charge_voltage_limit(3.841f);
mu_assert_double_eq(3.840, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(3.840, (double)furi_hal_power_get_battery_charge_voltage_limit());

furi_hal_power_set_battery_charge_voltage_limit(3.900f);
mu_assert_double_eq(3.888, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(3.888, (double)furi_hal_power_get_battery_charge_voltage_limit());

furi_hal_power_set_battery_charge_voltage_limit(4.200f);
mu_assert_double_eq(4.192, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(4.192, (double)furi_hal_power_get_battery_charge_voltage_limit());
}

MU_TEST(test_power_charge_voltage_limit_invalid_clamped) {
// Out-of-range charge voltage limits get clamped to 3.840 V and 4.208 V
furi_hal_power_set_battery_charge_voltage_limit(3.808f);
mu_assert_double_eq(3.840, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(3.840, (double)furi_hal_power_get_battery_charge_voltage_limit());
furi_hal_power_set_battery_charge_voltage_limit(1.0f);
mu_assert_double_eq(3.840, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(3.840, (double)furi_hal_power_get_battery_charge_voltage_limit());

// NOTE: Intentionally picking a small increment above 4.208 V to reduce the risk of an
// unhappy battery if this fails.
furi_hal_power_set_battery_charge_voltage_limit(4.240f);
mu_assert_double_eq(4.208, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(4.208, (double)furi_hal_power_get_battery_charge_voltage_limit());
// Likewise, picking a number that the uint8_t wraparound in the driver would result in a
// VREG value under 23 if this test fails.
// E.g. (uint8_t)((8105-3840)/16) -> 10
furi_hal_power_set_battery_charge_voltage_limit(8.105f);
mu_assert_double_eq(4.208, furi_hal_power_get_battery_charge_voltage_limit());
mu_assert_double_eq(4.208, (double)furi_hal_power_get_battery_charge_voltage_limit());
}

MU_TEST_SUITE(test_power_suite) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <furi.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep
#include <toolbox/protocols/protocol_dict.h>

typedef enum {
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/unit_tests/tests/rpc/rpc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <lib/toolbox/path.h>

#include <m-list.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#include <protobuf_version.h>
#include <pb.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../test.h"
#include "../test.h" // IWYU pragma: keep
#include <furi.h>
#include <storage/storage.h>

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/unit_tests/tests/stream/stream_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <toolbox/stream/file_stream.h>
#include <toolbox/stream/buffered_file_stream.h>
#include <storage/storage.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep

static const char* stream_test_data = "I write differently from what I speak, "
"I speak differently from what I think, "
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/unit_tests/tests/subghz/subghz_test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <furi.h>
#include <furi_hal.h>
#include "../test.h"
#include "../test.h" // IWYU pragma: keep
#include <lib/subghz/receiver.h>
#include <lib/subghz/transmitter.h>
#include <lib/subghz/subghz_keystore.h>
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/unit_tests/tests/varint/varint_test.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <furi.h>
#include <furi_hal.h>

#include "../test.h"
#include "../test.h" // IWYU pragma: keep

#include <toolbox/varint.h>
#include <toolbox/profiler.h>
Expand Down
1 change: 0 additions & 1 deletion applications/main/archive/helpers/archive_apps.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "archive_files.h"
#include "archive_apps.h"
#include "archive_browser.h"

Expand Down
Loading
Loading