Summary: | app-misc/fdupes-1.51 fails to compile on musl | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Michael Jones <gentoo> |
Component: | Current packages | Assignee: | Gentoo Shell Tools project <shell-tools> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bugdal, felix.janda, musl |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 430702 |
Description
Michael Jones
2016-02-13 08:50:01 UTC
(In reply to Michael Jones from comment #0) > fdupes.c: In function ‘main’: > fdupes.c:1172:13: error: assignment of read-only variable ‘stdin’ > stdin = freopen("/dev/tty", "r", stdin); > ^ I'm going to ask Rich about this one, or look directly at the POSIX standards because musl intentionally makes stdin read-only. I don't understand why some programs do this instead of using dup2() or similar. (In reply to Anthony Basile from comment #1) > (In reply to Michael Jones from comment #0) > > > fdupes.c: In function ‘main’: > > fdupes.c:1172:13: error: assignment of read-only variable ‘stdin’ > > stdin = freopen("/dev/tty", "r", stdin); > > ^ > > I'm going to ask Rich about this one, or look directly at the POSIX > standards because musl intentionally makes stdin read-only. I don't > understand why some programs do this instead of using dup2() or similar. Actually it should be as easy as just dropping `stdin =`. This at least works for stdout as in this little program: #include <stdio.h> int main() { freopen("zzz.txt", "w", stdout); printf("hi\n"); } So I'm not sure why people do stdin = freopen(..); It's not POSIX related, just plain C. stdin is specified as a macro that expands to an expression (think rvalue) of type FILE *. It need not even be an lvalue, much less one for which assignment is possible. Indeed just dropping the assignment is fine too. freopen only has two possible return values. On success it returns the same FILE * you passed into it. On failure it returns 0 (and the FILE * you passed in has been closed, so there's no way to recover and you probably need to exit immediately). Its in the overlay, I'm going to see about getting a patch upstream. Actually Felix already got a patch upstream https://github.com/adrianlopezroche/fdupes/commit/fe2d8334bfa28ff05fa1a2ffe8555a19b41be0ea but its a bit stale with https://github.com/adrianlopezroche/fdupes/commit/03abad92b65b3d7174349ae2cbd08177afec1b79 Both of those patches nail the issue correctly. @darkside, heroxbd, jlec, monsieurp, zlg is it okay if I back port those two patches? Sure, go ahead! Looks good to me. done |