1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00
Files
Bartosz Golaszewski 2de4e60262 tools: gpioset: store interactive sleep period in a long long
The interactive 'sleep' command stored the result of parse_period() in
an int. parse_period() returns a long long number of microseconds, so a
period above INT_MAX microseconds (~36 minutes, e.g. "sleep 40m")
overflowed: it could wrap to a negative value and be wrongly rejected as
an invalid period, or to an incorrect positive value producing the wrong
sleep duration.

Declare period_us as long long to match parse_period()'s return type.
The error check (period_us < 0) and the sleep_us() call, which takes an
unsigned long long, both remain correct. The non-interactive hold and
toggle period paths already use unsigned long long and were unaffected.

Add a test that issues "sleep 40m" at the interactive prompt and verifies
the tool starts sleeping rather than emitting an "invalid period" error

Fixes: c34a572c53 ("tools: add minutes as a new supported time unit")
Assisted-by: Claude Opus 4.8
Link: https://patch.msgid.link/20260608-more-pre-2-3-fixes-v1-5-577a5ba426a5@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-06-15 09:38:16 +02:00
..
2026-05-07 09:39:26 +02:00
2026-05-07 09:39:26 +02:00
2026-05-18 10:35:51 +02:00
2026-05-18 10:35:51 +02:00