martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.21k stars 258 forks source link

text: ignore unused-result in error path #893

Closed eworm-de closed 3 years ago

eworm-de commented 3 years ago

We are in error path and there's nothing we can do. Just ignore.

As clang tries to be compatible with gcc this should be portable.

martanne commented 3 years ago

I don't like to clutter the source with ugly #pragma stuff just to shut up compiler warnings. It might also not be supported by more niche compilers like cproc which are known to compile vis without problems. Casting the return value to void would be acceptable, but it seems like gcc decided to ignore that long standing idiom and warn anyway.

Also the the code path is currently never taken because the function is always called with AT_FDCWD. It was done in preparation for some experimentation with a client/server architecture where the the file descriptor could be passed from the client to the server.

eworm-de commented 3 years ago

Yes, all current solutions are more or less ugly... No idea why casting to void does no longer work. How about something like this?

if (fchdir(cwd)) /* ignore return */ ;