c
#include <stdbool.h>

static bool safe_add(ble_npl_time_t a, int32_t b, ble_npl_time_t* result) {
    if (b > 0 && a > UINT32_MAX - b) return false;
    if (b < 0 && a < (ble_npl_time_t)(-b)) return false;
    *result = a + b;
    return true;
}

static void
ble_hs_timer_sched(int32_t ticks_from_now)
{
    ble_npl_time_t abs_time;
    if (ticks_from_now == BLE_HS_FOREVER) {
        return;
    }
    if (!safe_add(ble_npl_time_get(), ticks_from_now, &abs_time)) {
        // Handle error, e.g., log it and set to max or min value
        abs_time = (ticks_from_now > 0) ? UINT32_MAX : 0;
    }
    // ... rest of the function
}
