Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
Fix formatting issues reported by clang-format version 18.
  • Loading branch information
RoEdAl committed May 9, 2024
1 parent 8720db8 commit 578b5bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/at_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};

/*!
Expand Down
24 changes: 12 additions & 12 deletions src/pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/*!
Expand Down

0 comments on commit 578b5bc

Please sign in to comment.