Re: [patch] Fix type errors in inotify interfaces

From: Michael Kerrisk
Date: Tue Nov 18 2008 - 15:23:33 EST


I hope Robert doesn't mind if I drop a piece from our old offlist mail
conversation into this thread, for some background.

-------- Original Message --------
Subject: Re: Use of uint32_t in inotify APIs
Date: Tue, 20 Jun 2006 09:07:17 -0400
From: Robert Love <rlove@xxxxxxxxx>

On 6/20/06, Michael Kerrisk wrote:

Hi,

> The use of uint32_t seems a little strange in at least some of the
> above. In particular, the watch descriptor returned by
> inotify_add_watch() is an "int", as is the "wd" field of the
> "inotify_event" structure, but in the prototype for inotify_rm_watch(),
> "wd" is uint32_t. Is there a reason for this, or is it just cruft?

The unsigned parameter in inotify_rm_watch() is wrong. I cannot think
we that should be the case. But the problem lies not with glibc --
the function definition in the kernel is wrong, too. It should be
fixed; everywhere else a watch descriptor is an __s32.

> Following on from this, is it really necessary that "mask" is uint32_t
> in the prototype for inotify_rm_watch()? In most other glibc
> interfaces, bit masks are simply "int".

I think masks should be unsigned. This definitely makes sense.

In the kernel, most of the inotify data types are __u32.

[...]

Also the 'wd' in the event structure should be 'int32_t' -- the kernel
uses the type '__s32' -- but perhaps glibc developers prefer to use a
straight 'int' since the types are identical.

In that case, inotify_rm_watch()'s 'wd' should be changed to '__s32'
in the kernel and 'int' in glibc. Otherwise, '__s32' in the kernel
and 'int32_t' in glibc. Since this change will affect ABI, it needs
to be made cautiously, but I don't see any issues.

Robert Love
--
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/