From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: "linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>
Subject: watchdog ioctl inconsistencies
Date: Mon, 26 Aug 2019 14:54:31 +0200 [thread overview]
Message-ID: <2d39e6c4-c9ef-4dce-4cce-14b77f331f81@rasmusvillemoes.dk> (raw)
Hi,
uapi/linux/watchdog.h has these
#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int)
This is a write from userspace perspective, so should have been _IOW.
#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int)
This one doesn't actually take an argument, so should just have been an
_IO - or if anything, an _IOW. One could be misled to think that if the
int argument has 'V' somewhere (perhaps first or last byte, depending on
endianness) that would count as a magic close.
#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int)
#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int)
The SETTIMEOUT handling does fall through to the GETTIMEOUT case, so
that one is indeed a "write this, but tell me what value actually took
effect". The SETPRETIMEOUT case ends with a break, so that one is really
_IOW.
There's not much to do about these, I think, but perhaps one could add a
comment to the uapi header containing the magic explains-all phrase
"historical reasons".
Does any static checker actually know about these conventions and peek
inside the _IO*() macros when used as an argument to ioctl(), comparing
the type and constness of the third argument to the direction/type
implied by the macro?
Rasmus
next reply other threads:[~2019-08-26 12:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-26 12:54 Rasmus Villemoes [this message]
2019-08-27 0:19 ` watchdog ioctl inconsistencies Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d39e6c4-c9ef-4dce-4cce-14b77f331f81@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=linux-watchdog@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).