-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/unix: InotifyRmWatch should take int, not uint32 #32020
Comments
The definition in syscall_linux.go dates back to 5 years ago, but it does look mismatched. /cc owners @ianlancetaylor @bradfitz @tklauser |
I guess it depends whether changing it would do more good than harm. I suspect it'd break a number of people and the benefit of changing it seems low-ish. |
This looks like discrepancy. Refering to inotify man pages: int inotify_rm_watch(int fd, int wd); https://www.man7.org/linux/man-pages/man2/inotify_add_watch.2.html int inotify_add_watch(int fd, const char *pathname, uint32_t mask); wd and return values when adding watch in inotify are of the same types. Go code is generated from: src/syscall/syscall_linux.go
uint32 is generally used for masks and modes Even found in old articles it's always stated as int: In linux kernel we can see:
types.h showing
|
Perhaps we made a mistake, but changing this now would just break existing working code for no benefit. |
Ok, it would break existing working code, but this hangs for more than 5 years. I would like to ask: when it could be fixed? |
@ianlancetaylor Now we have versions, so maybe, there's a chance to have |
Yes, we could fix this with a v2 package. But it seems like a minor detail. Perhaps I've missed something, but is there anything that can't be done with the current implementation? Aren't we just talking about adding a type conversion that shouldn't be needed? And it's not like this is a widely used function. |
It brings inconsistency and unnecessary checks/conversions on developer side. Could you elaborate more on not widely used function? |
It's not a widely used function, which means that few programmers will run into this inconsistency. We take backward compatibility seriously (see https://go.dev/doc/go1compat), so even though only a few programs use this function we aren't going to break them without a really good reason. The situation is clearly unfortunate, and I wish we had done better back when this function was introduced in 2010 (https://golang.org/cl/2241045). However, in a case like this, where there is no good solution and no clear path forward, not changing anything is the best of a set of bad choices. |
Could we at least mark it to be fixed in future? |
As long as we understand that the future is a very long way off, sure. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, https://github.com/golang/sys/blob/master/unix/zsyscall_linux_arm64.go still shows the following signature:
InotifyRmWatch(fd int, watchdesc uint32)
.What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
According to
man
,inotify_rm_watch
is defined as:int inotify_rm_watch(int fd, int wd)
. So I would expectInotifyRmWatch
to take two regular ints.What did you see instead?
Compiler complaining about type conversion (int -> uint32).
The text was updated successfully, but these errors were encountered: