From 578b5bc74ba13a8d6197b550c7a51ee366c3b252 Mon Sep 17 00:00:00 2001 From: Edmunt Pienkowsky Date: Thu, 9 May 2024 08:29:28 +0200 Subject: [PATCH] Fix formatting Fix formatting issues reported by clang-format version 18. --- src/at_response.c | 8 ++++---- src/pdu.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/at_response.c b/src/at_response.c index 2b14a7e9..d78f8514 100644 --- a/src/at_response.c +++ b/src/at_response.c @@ -54,15 +54,15 @@ static const int DST_DEF_LEN = 32; static const at_response_t at_responses_list[] = { AT_RESPONSES_TABLE(AT_RES_AS_STRUCTLIST) - - /* The hackish way to define the duplicated responses in the meantime */ +/* clang-format off */ + /* The hackish way to define the duplicated responses in the meantime */ #define DEF_STR(str) str, STRLEN(str) - {RES_CNUM, "+CNUM", DEF_STR("ERROR+CNUM:") }, + {RES_CNUM, "+CNUM", DEF_STR("ERROR+CNUM:") }, {RES_ERROR, "ERROR", DEF_STR("COMMAND NOT SUPPORT\r")}, #undef DEF_STR + /* clang-format on */ }; - const at_responses_t at_responses = {at_responses_list, 3, ARRAY_LEN(at_responses_list), RES_MIN, RES_MAX}; /*! diff --git a/src/pdu.c b/src/pdu.c index 440d5af3..4783034e 100644 --- a/src/pdu.c +++ b/src/pdu.c @@ -335,33 +335,33 @@ static char pdu_code2digit(uint8_t code) } } +static int div_up(unsigned int minutes, int divisor) { return (minutes + divisor - 1) / divisor; } + #/* convert minutes to relative VP value */ static int pdu_relative_validity(unsigned minutes) { -#define DIV_UP(x, y) (((x) + (y)-1) / (y)) + /* clang-format off */ /* - 0 ... 143 (vp + 1) * 5 minutes 5 ... 720 m = (vp + 1) * 5 m / 5 - 1 = vp - 144...167 12 hours + (vp - 143) * 30 minutes 750 ... 1440 m = 720 + (vp - 143) * 30 (m - 720) / - 30 + 143 = m / 30 + 119 - 168...196 (vp - 166) * 1 day 2880 ... 43200 m = (vp - 166) * 1440 (m / 1440) + 166 - 197...255 (vp - 192) * 1 week 50400 ...635040 m = (vp - 192) * 10080 (m / 10080) + - 192 + 0 ... 143 (vp + 1) * 5 minutes 5...720 m = (vp + 1) * 5 m / 5 - 1 = vp + 144...167 12 hours + (vp - 143) * 30 minutes 750...1440 m = 720 + (vp - 143) * 30 (m - 720) / 30 + 143 = m / 30 + 119 + 168...196 (vp - 166) * 1 day 2880...43200 m = (vp - 166) * 1440 (m / 1440) + 166 + 197...255 (vp - 192) * 1 week 50400...635040 m = (vp - 192) * 10080 (m / 10080) + 192 */ + /* clang-format on */ int validity; if (minutes <= 720) { - validity = DIV_UP(minutes, 5) - 1; + validity = div_up(minutes, 5) - 1; } else if (minutes <= 1440) { - validity = DIV_UP(minutes, 30) + 119; + validity = div_up(minutes, 30) + 119; } else if (minutes <= 43200) { - validity = DIV_UP(minutes, 1440) + 166; + validity = div_up(minutes, 1440) + 166; } else if (minutes <= 635040) { - validity = DIV_UP(minutes, 10080) + 192; + validity = div_up(minutes, 10080) + 192; } else { validity = 0xFF; } return validity; -#undef DIV_UP } /*!