Skip to content

Commit b5dae34

Browse files
gmarullnschonniclaude
committed
treewide: apply clang-format
Run clang-format 22 over every tracked C and proto source that is not excluded by .clang-format-ignore. A second pass was needed on a handful of files where trailing comment alignment is not stable after one run. Co-authored-by: Nick Schonning <nschonni@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
1 parent 27922ec commit b5dae34

2,278 files changed

Lines changed: 61569 additions & 63787 deletions

File tree

Some content is hidden

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

apps/samples/accelerometer_peek_test/src/accelerometer_peek_test.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
#include <inttypes.h>
66

77
#define ACCEL_RAW_DATA 0
8-
#define TIMEOUT_MS 1000
8+
#define TIMEOUT_MS 1000
99

1010
Window *window;
1111
TextLayer *text_layer;
1212

13-
AppTimer* s_timer;
13+
AppTimer *s_timer;
1414
static AccelData s_last_accel_data;
1515

1616
static uint32_t prv_compute_delta_pos(AccelData *cur_pos, AccelData *last_pos) {
1717
return (abs(last_pos->x - cur_pos->x) + abs(last_pos->y - cur_pos->y) +
18-
abs(last_pos->z - cur_pos->z));
18+
abs(last_pos->z - cur_pos->z));
1919
}
2020

2121
static void prv_timer_cb(void *data) {
@@ -33,11 +33,11 @@ static void prv_timer_cb(void *data) {
3333
int32_t delta = prv_compute_delta_pos(&accel_data, &s_last_accel_data);
3434
s_last_accel_data = accel_data;
3535

36-
snprintf(accel_text, sizeof(accel_text), "Accel delta: %"PRIu32, delta);
36+
snprintf(accel_text, sizeof(accel_text), "Accel delta: %" PRIu32, delta);
3737
APP_LOG(APP_LOG_LEVEL_INFO, accel_text);
3838
#else
39-
snprintf(accel_text, sizeof(accel_text), "x:%"PRId16 ", y:%"PRId16 ", z:%"PRId16,
40-
accel_data.x, accel_data.y, accel_data.z);
39+
snprintf(accel_text, sizeof(accel_text), "x:%" PRId16 ", y:%" PRId16 ", z:%" PRId16, accel_data.x,
40+
accel_data.y, accel_data.z);
4141
APP_LOG(APP_LOG_LEVEL_INFO, accel_text);
4242
#endif
4343
text_layer_set_text(text_layer, accel_text);
@@ -50,8 +50,8 @@ void handle_init(void) {
5050
GRect bounds = layer_get_bounds(window_layer);
5151
uint32_t text_width = bounds.size.w;
5252
uint32_t text_height = 28;
53-
text_layer = text_layer_create(GRect(0, bounds.size.h/2 - text_height/2,
54-
text_width, text_height));
53+
text_layer =
54+
text_layer_create(GRect(0, bounds.size.h / 2 - text_height / 2, text_width, text_height));
5555

5656
// Set the text, font, and text alignment
5757
text_layer_set_text(text_layer, "No Accelerometer");

apps/samples/app_heap_demo/src/app_heap_demo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <pebble.h>
55

6-
#define ALLOC_SIZE 2048
6+
#define ALLOC_SIZE 2048
77

88
static Window *window;
99
static TextLayer *text_heap_info;

apps/samples/app_messages_test/src/app_message_test.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
static Window *s_window;
77
static TextLayer *s_text_layer;
88

9-
109
enum {
1110
DICT_KEY_TEST_0 = 0x0,
1211
};
@@ -31,7 +30,7 @@ static int send_app_msg(void) {
3130
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
3231
int result;
3332
APP_LOG(APP_LOG_LEVEL_DEBUG, "Sending messages");
34-
for (int i=0; i<10; i++) {
33+
for (int i = 0; i < 10; i++) {
3534
APP_LOG(APP_LOG_LEVEL_DEBUG, "app sending outbox");
3635
do {
3736
result = send_app_msg();
@@ -42,7 +41,7 @@ static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
4241

4342
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
4443
text_layer_set_text(s_text_layer, "Up");
45-
for (int i=0; i<10; i++) {
44+
for (int i = 0; i < 10; i++) {
4645
APP_LOG(APP_LOG_LEVEL_INFO, "sending BT log message");
4746
}
4847
}
@@ -82,7 +81,7 @@ static void window_load(Window *window) {
8281
Layer *window_layer = window_get_root_layer(window);
8382
GRect bounds = layer_get_bounds(window_layer);
8483

85-
s_text_layer = text_layer_create((GRect) { .origin = { 0, 72 }, .size = { bounds.size.w, 20 } });
84+
s_text_layer = text_layer_create((GRect){.origin = {0, 72}, .size = {bounds.size.w, 20}});
8685
text_layer_set_text(s_text_layer, "Press a button");
8786
text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
8887
layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
@@ -95,10 +94,10 @@ static void init(void) {
9594
s_window = window_create();
9695
app_message_init();
9796
window_set_click_config_provider(s_window, click_config_provider);
98-
window_set_window_handlers(s_window, (WindowHandlers) {
99-
.load = window_load,
100-
.unload = window_unload,
101-
});
97+
window_set_window_handlers(s_window, (WindowHandlers){
98+
.load = window_load,
99+
.unload = window_unload,
100+
});
102101
const bool animated = true;
103102
window_stack_push(s_window, animated);
104103
}

apps/samples/bg_task_test/src/fg.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "pebble.h"
55
#include <inttypes.h>
66

7-
87
Window *window;
98
TextLayer *text_layer;
109
Layer *line_layer;
@@ -18,21 +17,22 @@ static uint64_t prv_ms(void) {
1817
return ((uint64_t)cur_sec * 1000) + cur_ms;
1918
}
2019

21-
2220
static void steps_event_handler(uint16_t type, AppWorkerMessage *data) {
23-
//APP_LOG(APP_LOG_LEVEL_DEBUG, "Received new worker event. type: %d, data: %d, %d, %d", (int)type, (int)data->data0,
24-
// (int)data->data1, (int)data->data2);
21+
// APP_LOG(APP_LOG_LEVEL_DEBUG, "Received new worker event. type: %d, data: %d, %d, %d",
22+
// (int)type, (int)data->data0,
23+
// (int)data->data1, (int)data->data2);
2524

2625
if (type == 0) {
27-
snprintf(g_text, sizeof(g_text), "%5d %5d %5d", (int)data->data0, (int)data->data1, (int)data->data2);
26+
snprintf(g_text, sizeof(g_text), "%5d %5d %5d", (int)data->data0, (int)data->data1,
27+
(int)data->data2);
2828
text_layer_set_text(text_layer, g_text);
2929
} else if (type == 1) {
30-
snprintf(g_text, sizeof(g_text), "BAT: %d, %d, %d", (int)data->data0, (int)data->data1, (int)data->data2);
30+
snprintf(g_text, sizeof(g_text), "BAT: %d, %d, %d", (int)data->data0, (int)data->data1,
31+
(int)data->data2);
3132
text_layer_set_text(text_layer, g_text);
3233
}
3334
}
3435

35-
3636
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
3737
AppWorkerResult result = app_worker_launch();
3838
APP_LOG(APP_LOG_LEVEL_INFO, "launch result: %d", result);
@@ -57,11 +57,10 @@ static void click_config_provider(void *context) {
5757

5858
static uint32_t s_seconds_count;
5959
void handle_second_tick(struct tm *tick_time, TimeUnits units_changed) {
60-
6160
bool running = app_worker_is_running();
6261

6362
if (false) {
64-
const char* status = "not";
63+
const char *status = "not";
6564
if (running) {
6665
status = "is";
6766
}
@@ -77,12 +76,11 @@ void handle_second_tick(struct tm *tick_time, TimeUnits units_changed) {
7776
}
7877

7978
static void health_event_handler(HealthEventType event, void *context) {
80-
APP_LOG(APP_LOG_LEVEL_INFO, "app: Got health event update. event_id: %"PRIu32"",
81-
(uint32_t) event);
79+
APP_LOG(APP_LOG_LEVEL_INFO, "app: Got health event update. event_id: %" PRIu32 "",
80+
(uint32_t)event);
8281
if (event == HealthEventMovementUpdate) {
8382
HealthValue steps = health_service_sum_today(HealthMetricStepCount);
84-
APP_LOG(APP_LOG_LEVEL_INFO, "app: movement event, steps: %"PRIu32"",
85-
(uint32_t)steps);
83+
APP_LOG(APP_LOG_LEVEL_INFO, "app: movement event, steps: %" PRIu32 "", (uint32_t)steps);
8684

8785
// Test getting historical steps
8886
time_t day_start = time_start_of_today();
@@ -102,34 +100,36 @@ static void health_event_handler(HealthEventType event, void *context) {
102100
steps = health_service_sum(HealthMetricStepCount, day_start - (SECONDS_PER_DAY / 2), day_start);
103101
APP_LOG(APP_LOG_LEVEL_INFO, "steps 2nd half of yesterday: %d", (int)steps);
104102

105-
106103
// Test the get_minute_history call
107104

108105
const int minute_data_len = 10;
109106
HealthMinuteData minute_data[minute_data_len];
110107
uint32_t num_records = minute_data_len;
111-
time_t utc_start = time(NULL) - 60 * 60 * 24; // All records since 1 day ago
108+
time_t utc_start = time(NULL) - 60 * 60 * 24; // All records since 1 day ago
112109
time_t utc_end = time(NULL);
113110

114111
uint64_t start_ms = prv_ms();
115112
health_service_get_minute_history(minute_data, num_records, &utc_start, &utc_end);
116113
uint64_t elapsed_ms = prv_ms() - start_ms;
117114

118115
int num_records_returned = (utc_end - utc_start) / SECONDS_PER_MINUTE;
119-
APP_LOG(APP_LOG_LEVEL_INFO, "app: Retrieved %d minute records in %"PRIu32" ms:",
120-
num_records_returned, (uint32_t)elapsed_ms);
116+
APP_LOG(APP_LOG_LEVEL_INFO,
117+
"app: Retrieved %d minute records in %" PRIu32 " ms:", num_records_returned,
118+
(uint32_t)elapsed_ms);
121119
for (int i = 0; i < num_records_returned; i++) {
122-
APP_LOG(APP_LOG_LEVEL_INFO, " steps: %"PRIu8", orient: 0x%"PRIx8", vmc: %"PRIu16", "
123-
"light: %d, valid: %d", minute_data[i].steps, minute_data[i].orientation,
124-
minute_data[i].vmc, (int)minute_data[i].light, (int)(!minute_data[i].is_invalid));
120+
APP_LOG(APP_LOG_LEVEL_INFO,
121+
" steps: %" PRIu8 ", orient: 0x%" PRIx8 ", vmc: %" PRIu16
122+
", "
123+
"light: %d, valid: %d",
124+
minute_data[i].steps, minute_data[i].orientation, minute_data[i].vmc,
125+
(int)minute_data[i].light, (int)(!minute_data[i].is_invalid));
125126
}
126127

127-
128128
} else if (event == HealthEventSleepUpdate) {
129129
HealthValue total_sleep = health_service_sum_today(HealthMetricSleepSeconds);
130130
HealthValue restful_sleep = health_service_sum_today(HealthMetricSleepRestfulSeconds);
131-
APP_LOG(APP_LOG_LEVEL_INFO, "app: New sleep event: total: %"PRIu32", restful: %"PRIu32" ",
132-
total_sleep / SECONDS_PER_MINUTE, restful_sleep / SECONDS_PER_MINUTE);
131+
APP_LOG(APP_LOG_LEVEL_INFO, "app: New sleep event: total: %" PRIu32 ", restful: %" PRIu32 " ",
132+
total_sleep / SECONDS_PER_MINUTE, restful_sleep / SECONDS_PER_MINUTE);
133133
}
134134
}
135135

@@ -147,7 +147,7 @@ void handle_init(void) {
147147

148148
Layer *window_layer = window_get_root_layer(window);
149149

150-
text_layer = text_layer_create(GRect(7, 40, 144-7, 168-40));
150+
text_layer = text_layer_create(GRect(7, 40, 144 - 7, 168 - 40));
151151
text_layer_set_text_color(text_layer, GColorWhite);
152152
text_layer_set_background_color(text_layer, GColorClear);
153153
text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
@@ -170,11 +170,10 @@ void handle_init(void) {
170170
health_service_events_subscribe(health_event_handler, NULL);
171171
}
172172

173-
174173
int main(void) {
175174
handle_init();
176175

177176
app_event_loop();
178-
177+
179178
handle_deinit();
180179
}

apps/samples/bg_task_test/worker_src/bg.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define PERSIST_WRITE_PERIOD_MS 1000
1111

1212
// -------------------------------------------------------------------------------------------------
13-
static void prv_assert(bool condition, const char* msg) {
13+
static void prv_assert(bool condition, const char *msg) {
1414
if (!condition) {
1515
APP_LOG(APP_LOG_LEVEL_ERROR, msg);
1616

@@ -23,10 +23,10 @@ static void prv_assert(bool condition, const char* msg) {
2323

2424
// -----------------------------------------------------------------------------------------------
2525
void handle_accel(AccelRawData *accel_data, uint32_t num_samples, uint64_t timestamp) {
26-
2726
// Display data
28-
//for (uint32_t i=0; i<num_samples; i++) {
29-
// APP_LOG(APP_LOG_LEVEL_INFO, "Got accel data: %d, %d, %d", accel_data[i].x, accel_data[i].y, accel_data[i].z);
27+
// for (uint32_t i=0; i<num_samples; i++) {
28+
// APP_LOG(APP_LOG_LEVEL_INFO, "Got accel data: %d, %d, %d", accel_data[i].x, accel_data[i].y,
29+
// accel_data[i].z);
3030
//}
3131

3232
// Publish new steps count
@@ -39,19 +39,18 @@ void handle_accel(AccelRawData *accel_data, uint32_t num_samples, uint64_t times
3939
}
4040

4141
// -----------------------------------------------------------------------------------------------
42-
static void update_persist_callback(void* context) {
42+
static void update_persist_callback(void *context) {
4343
int value = persist_read_int(42);
4444
// APP_LOG(APP_LOG_LEVEL_INFO, "Updating persist value from %d to %d", value, value + 1);
4545
persist_write_int(42, value + 1);
4646
app_timer_register(PERSIST_WRITE_PERIOD_MS /*ms*/, update_persist_callback, NULL);
4747
}
4848

49-
5049
// -----------------------------------------------------------------------------------------------
5150
static void battery_state_handler(BatteryChargeState charge) {
5251
APP_LOG(APP_LOG_LEVEL_INFO, "got battery state service update");
5352
APP_LOG(APP_LOG_LEVEL_INFO, "percent: %d, is_charging: %d, is_plugged: %d", charge.charge_percent,
54-
charge.is_charging, charge.is_plugged);
53+
charge.is_charging, charge.is_plugged);
5554

5655
AppWorkerMessage battery_data = {
5756
.data0 = charge.charge_percent,
@@ -61,42 +60,38 @@ static void battery_state_handler(BatteryChargeState charge) {
6160
app_worker_send_message(1 /*type*/, &battery_data);
6261
}
6362

64-
6563
// -----------------------------------------------------------------------------------------------
6664
static void connection_handler(bool connected) {
6765
APP_LOG(APP_LOG_LEVEL_INFO, "got phone connection update");
6866
APP_LOG(APP_LOG_LEVEL_INFO, "connected: %d", connected);
6967
}
7068

71-
7269
// -----------------------------------------------------------------------------------------------
7370
static void tick_timer_handler(struct tm *tick_time, TimeUnits units_changed) {
7471
APP_LOG(APP_LOG_LEVEL_INFO, "got tick timer update");
7572
}
7673

77-
7874
// -----------------------------------------------------------------------------------------------
7975
static void worker_message_handler(uint16_t type, AppWorkerMessage *data) {
8076
if (type == 'x') {
8177
prv_assert(0, "crashing");
8278
}
8379
}
8480

85-
8681
// -----------------------------------------------------------------------------------------------
8782
static void health_event_handler(HealthEventType event, void *context) {
88-
APP_LOG(APP_LOG_LEVEL_INFO, "worker: Got health event update. event_id: %"PRIu32"",
89-
(uint32_t) event);
83+
APP_LOG(APP_LOG_LEVEL_INFO, "worker: Got health event update. event_id: %" PRIu32 "",
84+
(uint32_t)event);
9085
if (event == HealthEventMovementUpdate) {
9186
HealthValue steps = health_service_sum_today(HealthMetricStepCount);
92-
APP_LOG(APP_LOG_LEVEL_INFO, "worker: movement event, steps: %"PRIu32"",
93-
(uint32_t)steps);
87+
APP_LOG(APP_LOG_LEVEL_INFO, "worker: movement event, steps: %" PRIu32 "", (uint32_t)steps);
9488

9589
} else if (event == HealthEventSleepUpdate) {
9690
HealthValue total_sleep = health_service_sum_today(HealthMetricSleepSeconds);
9791
HealthValue restful_sleep = health_service_sum_today(HealthMetricSleepRestfulSeconds);
98-
APP_LOG(APP_LOG_LEVEL_INFO, "worker: New sleep event: total: %"PRIu32", restful: %"PRIu32" ",
99-
total_sleep / SECONDS_PER_MINUTE, restful_sleep / SECONDS_PER_MINUTE);
92+
APP_LOG(APP_LOG_LEVEL_INFO,
93+
"worker: New sleep event: total: %" PRIu32 ", restful: %" PRIu32 " ",
94+
total_sleep / SECONDS_PER_MINUTE, restful_sleep / SECONDS_PER_MINUTE);
10095
}
10196
}
10297

@@ -111,9 +106,7 @@ int main(void) {
111106

112107
battery_state_service_subscribe(battery_state_handler);
113108

114-
ConnectionHandlers conn_handlers = {
115-
.pebble_app_connection_handler = connection_handler
116-
};
109+
ConnectionHandlers conn_handlers = {.pebble_app_connection_handler = connection_handler};
117110
connection_service_subscribe(conn_handlers);
118111

119112
tick_timer_service_subscribe(MINUTE_UNIT, tick_timer_handler);
@@ -128,4 +121,3 @@ int main(void) {
128121
accel_data_service_unsubscribe();
129122
health_service_events_unsubscribe();
130123
}
131-

0 commit comments

Comments
 (0)