Skip to content

Commit

Permalink
treewide: Remove redefinitions of SEC_PER_HOUR and SEC_PER_DAY
Browse files Browse the repository at this point in the history
These macros are now provided by Zephyr (in sys_clock.h).

As these macros for mesh were defined with `unsigned long long` type
and now they are `unsigned long`, casting was added where needed to
avoid overflows.

Signed-off-by: Andrzej Głąbek <[email protected]>
  • Loading branch information
anangl committed Jan 15, 2025
1 parent c45f4a1 commit 43ff66f
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 11 deletions.
2 changes: 0 additions & 2 deletions applications/serial_lte_modem/src/gnss/slm_at_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ static struct modem_pipe *gnss_pipe;

#define LOCATION_REPORT_MS 5000

#define SEC_PER_HOUR (MIN_PER_HOUR * SEC_PER_MIN)
#define SEC_PER_DAY (HOUR_PER_DAY * SEC_PER_HOUR)
/* (6.1.1980 UTC - 1.1.1970 UTC) */
#define GPS_TO_UNIX_UTC_OFFSET_SECONDS (315964800UL)
/* UTC/GPS time offset as of 1st of January 2017. */
Expand Down
2 changes: 0 additions & 2 deletions samples/cellular/gnss/src/assistance_minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ LOG_MODULE_DECLARE(gnss_sample, CONFIG_GNSS_SAMPLE_LOG_LEVEL);
#define GPS_TO_UNIX_UTC_OFFSET_SECONDS (315964800UL)
/* UTC/GPS time offset as of 1st of January 2017. */
#define GPS_TO_UTC_LEAP_SECONDS (18UL)
#define SEC_PER_HOUR (MIN_PER_HOUR * SEC_PER_MIN)
#define SEC_PER_DAY (HOUR_PER_DAY * SEC_PER_HOUR)
#define DAYS_PER_WEEK (7UL)
#define PLMN_STR_MAX_LEN 8 /* MCC + MNC + quotes */

Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/mesh/time_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int ts_to_tai(struct bt_mesh_time_tai *tai, const struct tm *timeptr)

days += timeptr->tm_mday - 1;

tai->sec = (days * SEC_PER_DAY);
tai->sec = ((uint64_t)days * SEC_PER_DAY);
tai->sec += ((uint64_t)timeptr->tm_hour * SEC_PER_HOUR);
tai->sec += ((uint64_t)timeptr->tm_min * SEC_PER_MIN);
tai->sec += (uint64_t)timeptr->tm_sec;
Expand Down
2 changes: 0 additions & 2 deletions subsys/bluetooth/mesh/time_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ extern "C" {

#define DAYS_YEAR 365ULL
#define DAYS_LEAP_YEAR 366ULL
#define SEC_PER_HOUR (60ULL * SEC_PER_MIN)
#define SEC_PER_DAY (24ULL * SEC_PER_HOUR)

#define SEC_PER_YEAR (DAYS_YEAR * SEC_PER_DAY)
#define SEC_PER_LEAP_YEAR (DAYS_LEAP_YEAR * SEC_PER_DAY)
Expand Down
2 changes: 0 additions & 2 deletions subsys/bluetooth/services/cgms/cgms.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

LOG_MODULE_REGISTER(cgms, CONFIG_BT_CGMS_LOG_LEVEL);

#define SEC_PER_DAY 86400

#define CGMS_SVC_MEAS_ATTR_IDX 1
#define CGMS_SVC_RACP_ATTR_IDX 12
#define CGMS_SVC_SOCP_ATTR_IDX 15
Expand Down
2 changes: 0 additions & 2 deletions subsys/net/lib/nrf_cloud/include/nrf_cloud_pgps_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ extern "C" {
/* (6.1.1980 UTC - 1.1.1970 UTC) */
#define GPS_TO_UNIX_UTC_OFFSET_SECONDS (315964800UL)
#define GPS_TO_UTC_LEAP_SECONDS (18UL)
#define SEC_PER_HOUR (MIN_PER_HOUR * SEC_PER_MIN)
#define SEC_PER_DAY (HOUR_PER_DAY * SEC_PER_HOUR)
#define DAYS_PER_WEEK (7UL)
#define SECONDS_PER_WEEK (SEC_PER_DAY * DAYS_PER_WEEK)

Expand Down

0 comments on commit 43ff66f

Please sign in to comment.