Re: [PATCH v2 1/2] posix-timers: Prevents overrun counter overflow

From: Richard Cochran
Date: Sat Jan 24 2015 - 13:17:33 EST


On Sat, Jan 24, 2015 at 12:48:56PM -0500, Daniel Church wrote:
> +/*
> + * Updates a timer's overrun count while capping it to delaytimer_max
> + */
> +static void posix_timer_update_overrun_count(struct k_itimer *timer,
> + unsigned int overruns)
> +{
> + const bool newOverrunsAboveMax = overruns >= delaytimer_max;
> + const bool totalOverrunsAboveMax =
> + timer->it_overrun >= 0 &&
> + timer->it_overrun >= delaytimer_max - overruns;

Lower camel case is not a part of the kernel coding style.

Also, the 'const' keyword is useless in this context.

> +
> + if (newOverrunsAboveMax || totalOverrunsAboveMax) {
> + timer->it_overrun = delaytimer_max;
> + } else {
> + timer->it_overrun += overruns;
> + }
> +}
> +
> /* Get clock_realtime */
> static int posix_clock_realtime_get(clockid_t which_clock, struct timespec *tp)
> {
> @@ -1122,3 +1150,4 @@ long clock_nanosleep_restart(struct restart_block *restart_block)
>
> return kc->nsleep_restart(restart_block);
> }
> +

This stray newline and the camel case are the kinds of things that
checkpatch.pl will catch.

Thanks,
Richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/