Commit Graph

55 Commits

Author SHA1 Message Date
Kurtis Rader
51adf815aa Dragonfly BSD needs sys/socket.h
Commit 4bc220f removed `#include <sys/socket.h>` which breaks compiling
on Dragonfly BSD.
2017-01-14 19:53:27 -08:00
David Adam
4bc220f349 Drop requirement for socket library
The socket(2) library function is only required on Linux, and does not
require special linker arguments to work.

Closes #2360.
2017-01-11 19:34:32 +08:00
ridiculousfish
e5bfdb99b6 Enable mkostemp to be weak-linked
mkostemp is not available on some older versions of macOS. In order
for our built binaries to run on them, mkostemp must be weak-linked.
On other systems, we use the autoconf check.

Introduce a function fish_mkstemp_cloexec which uses mkostemp if
it was detected and is available at runtime, else falls back to
mkstemp. This isolates some logic that is currently duplicated in
two places.

See #3138 for more on weak linking.
2017-01-08 22:18:27 -08:00
Kurtis Rader
b118ed69d3 convert narrow stderr output to wide forms
On some platforms, notably GNU libc, you cannot mix narrow and wide
stdio functions on a stream like stdout or stderr. Doing so will drop
the output of one or the other. This change makes all output to the
stderr stream consistently use the wide forms.

This change also converts some fprintf(stderr,...) calls to debug()
calls where appropriate.

Fixes #3692
2017-01-03 16:14:42 -08:00
Kurtis Rader
7211802fc0 silence unused parmeter warning 2017-01-01 21:48:40 -08:00
Zoltán Mizsei
52c7ebe502 Haiku needs _BSD_SOURCE and <bsd/ifaddrs.h> 2016-12-27 16:00:13 -08:00
Kurtis Rader
574424dc5a fix uvar tests
I noticed that universal variable tests were failing on Cygwin and
Dragonfly BSD. The failures were because we are attempting to verify the
correct behavior of mechanisms that are known to be broken on those
platforms. There are still uvar test failures on those platforms with
this change but they are due to actual problems rather than bugs in the
tests.

Fixes #3587
2016-12-25 21:17:27 -08:00
Kurtis Rader
8ba2a4cfd4 fix race opening the uvar pipe
Fixes #3426
2016-12-21 16:32:43 -08:00
Kurtis Rader
483e9fdea2 check if locking takes too long
If acquiring a lock on the history or uvar file takes more than 250 ms
disable locking of the file. On systems with broken remote file system
locking it can cause tens of seconds delay after running each command
which can make the shell borderline unusable.

This also changes history file locking to use flock() rather than
fcntl() to be consistent with uvar file locking. It also implements the
250 ms time limit before giving up on locking.

Fixes #685
2016-12-16 21:20:08 -08:00
Kurtis Rader
9443a415bf time for another make style-all 2016-12-03 20:12:53 -08:00
David Adam
bf53f39cdd cppcheck: warn on use of flock 2016-12-03 16:36:06 +08:00
Kurtis Rader
eaa3741336 improve error msg about invalid HOME/XDG_* var
This change increases the amount of useful information when fish is
unable to create or use its config or data directory. We now make it
clear when neither var is set or one is set to an unusable location.

Fixes #3545
2016-12-01 20:40:25 -08:00
Aaron Gyes
682af2f83f Remove 4 cppcheck suppressions reported unmatched. 2016-11-28 11:54:03 -08:00
Fredrik Fornwall
df12ac24b2 Fix build on systems without shm_open()
Notably, this fixes building on Android.
2016-11-26 16:14:15 -05:00
Kurtis Rader
aad2848e80 use consistent mechanism to validate var names
Builtin commands that validate var names should use a consistent
mechanism. I noticed that builtin_read() had it's own custom code that
differed slightly from wcsvarname().

Fixes #3569
2016-11-22 16:18:20 -08:00
Kurtis Rader
521546a986 fix some lint warnings
This fixes some of the IWYU and cppcheck lint warnings. And only on
macOS (formerly OS X). Fixing these types of warnings on a broader set
of platforms should be done but this is a baby step to making `make
lint-all` have few, if any, warnings. This reduces the number of lines
in the `make lint-all` output on macOS by over 500 lines.
2016-11-15 21:15:22 -08:00
Kurtis Rader
f6047f02d6 lint: constant conditional operator 2016-11-01 21:19:34 -07:00
Kurtis Rader
71e69b6d75 lint: empty if statement 2016-11-01 20:42:02 -07:00
Kurtis Rader
f0ab1331a5 lint: Use early exit/continue 2016-10-29 21:46:11 -07:00
Kurtis Rader
25e0a39165 fix bug introduced by lint cleanup commit 42458ff 2016-10-22 21:14:21 -07:00
Kurtis Rader
42458ff7ab lint: "collapsible if statements" warnings 2016-10-22 19:09:40 -07:00
Kurtis Rader
00303ed07f lint cleanup: parameter reassignment 2016-10-20 18:53:31 -07:00
Kurtis Rader
c07c98ac05 eliminate many "unused parameter" warnings
Partially addresses issue #3430.
2016-10-09 14:38:26 -07:00
Kurtis Rader
851e449347 eliminate signed/unsigned comparison warnings
This partially addresses #3430.
2016-10-09 14:36:08 -07:00
Kurtis Rader
af0a2add10 fix check for unsupported op on BSD
Fixes #3362
2016-09-09 19:36:26 -07:00
David Adam
35bee00802 env_universal_common: drop MAP_FILE flag
MAP_FILE is unspecified or ignored on Linux, Solaris, FreeBSD and Haiku;
it is the default on OS X.

Work on #3317 & #3340.
2016-08-30 21:43:25 +08:00
jscipione
a872d9c299 make sure p->ifa_addr is not NULL before using it 2016-08-23 20:33:49 -07:00
Kurtis Rader
6c8ecab44b fix copy/paste bug in moving a block of code 2016-07-30 19:59:34 -07:00
Kurtis Rader
5da3d2f27b revert part of earlier "cleanup" change
Commit acfd3801 included a legitimate bug fix and a second change that
didn't correct an actual bug but made the code more fragile. Revert the
second part of that commit (while also suppressing the uninitialized
variable compiler warning that caused the ill-advised change).
2016-07-30 19:32:05 -07:00
Aaron Gyes
d51a1e4fe2 kill CAST_INIT, use reinterpret_cast<> on sockaddr
Just use static_cast directly instead of inscrutible "shortcut"
macro.

It was not always used and doesn't seem to do much besides scramble
things up; encountering CAST_INIT() in the code seems likely to lead
to head scratching due to the transformation taking place.

It was added to save folks typing the type twice, now with 100
columns available, let's roll that convenience macro back.

sockaddr_dl:

Perform reinterpret_cast<sockaddr_dl> conversion. The cast affected
alignment and looks fishy to a compiler (but it's fine). Ditch
C-style cast and communicate we're doing that on purpose.
2016-07-30 13:10:25 -07:00
Aaron Gyes
acfd380176 Fix two things -Wconditional-uninitialized warned about
Rather minor stuff:
* Initliaze first case to 0.
* The other (saved_errno), move the error output it is for
  in-scope and not need at all.
2016-07-30 03:34:46 -07:00
Kurtis Rader
1d2fff9686 simplify oclint error suppression for scoped_lock 2016-07-20 22:30:58 -07:00
Aaron Gyes
fa78a7101c Make IWYU output in lint.cpp less messy
And re-run IWYU, adjust #includes.
2016-06-23 17:26:08 -07:00
Aaron Gyes
b72ed1fa8c Fix env_universal_common.cpp filesize comparisons.
* if (result == ULLONG_MAX) is always false, likely a typo as
  result is unsigned long, and the comment says ULONG_MAX.

* use off_t instead of size_t for file size where it can mismatch
  st_size's type in stat.h
2016-06-12 03:52:58 -07:00
Kurtis Rader
5bf1b0e5f5 fix random lint issues
This only eliminates errors reported by `make lint`. It shouldn't cause any
functional changes.

This change does remove several functions that are unused. It also removes the
`desc_arr` variable which is both unused and out of date with reality.
2016-05-29 22:24:29 -07:00
Kurtis Rader
79f342b954 lint cleanup: eliminate "redundant" errors
This removes some pointless parentheses but the primary focus is removing
redundancies like unnecessary "else" clauses.
2016-05-04 15:32:04 -07:00
Kurtis Rader
690ceeeaa7 restyle env_universal module to match project style
Reduces lint errors from 121 to 52 (-57%). Line count from 1916 to 1671 (-13%).

Another step in resolving issue #2902.
2016-04-28 19:17:28 -07:00
David Adam
ac68c0c878 env_universal_common.cpp: pass correct flag to fcntl
Closes #2955.

(cherry picked from commit d5797c5439)
2016-04-27 20:46:12 +08:00
Kurtis Rader
1f06e5f0b9 add better support for IWYU and fix things
Remove the "make iwyu" build target. Move the functionality into the
recently introduced lint.fish script. Fix a lot, but not all, of the
include-what-you-use errors. Specifically, it fixes all of the IWYU errors
on my OS X server but only removes some of them on my Ubuntu 14.04 server.

Fixes #2957
2016-04-26 15:02:22 -07:00
ridiculousfish
d2ae00ca44 Remove a dead function bool_from_env_var 2016-04-07 13:29:50 -07:00
Kurtis Rader
47f1a92cc4 fixes for cppcheck lint warnings
Refine the linting behavior.

Fix several of the, mostly trivial, lint errors.
2016-04-04 14:34:28 -07:00
Kurtis Rader
411d573ba9 convert atypical env_universal_common logging
This is a quick and dirty conversion of the atypical, and undocumented,
logging done by env_universal_common.cpp to the usual `debug()` pattern. I
didn't want to drop the messages because they could be useful when
debugging future issues. So I simply converted them to the lowest debug
level using the normal debug() function.

Fixes #2887
2016-04-03 20:23:43 -07:00
David Adam
03460a3928 env_universal_common: use uid_t in geteuid checks
The u_int typedef fails to compile on all platforms (e.g. Windows). It
is part of the code imported from tmux.

Update it to the SUS-standard uid_t.

Closes #2821.
2016-03-18 15:53:29 -07:00
Jeff Kowalski
a7012648fe Improve error handling around fchown
Address the feedback from the prior commit:
- Change the sense of return value testing to match more common
comparison idiom
- Test result of fchmod as well as fchown
- Change sense of return value testing around wrename as well
- Include errno where possible in error message
2016-03-12 12:26:01 -08:00
Jeff Kowalski
46b9f263ac Handle return values from fchown
The function fchown is annotated with warn_unused_result.  As
formerly used in the code, it would emit a compiler warning
```warning: ignoring return value of ‘fchown’, declared with
attribute warn_unused_result [-Wunused-result]```

This commit notes the return value and emits appropriate error/logging
messages if the call fails, creating more traceable results and
satisfying the compiler.
2016-03-12 11:21:52 -08:00
ridiculousfish
58d56f91f3 Tweak UTF8 decoding interface
Previously, when decoding UTF-8, we would first run through the
array to compute the correct size, then allocate a buffer of that size,
then run through the array again to fill the buffer, and then copy it
into a std::wstring. With this fix we can copy it into the string
directly, reducing allocations and only requiring a single pass.
2016-03-02 11:24:23 -08:00
ridiculousfish
10f3ea0008 Mark a bunch of constructors as explicit
This prevents undesired implicit conversions
2016-02-27 19:38:15 -08:00
ridiculousfish
947f659f96 Miscellaneous cleanup and dead code removal
Noticed by cppcheck
2016-02-19 15:45:31 -08:00
Tanner Bruce
b4b5c2188f Check that $XDG_RUNTIME_DIR is valid and accessible
Signed-off-by: David Adam <zanchey@ucc.gu.uwa.edu.au>
2015-12-11 15:02:36 +08:00
David Adam
ce360bcfe3 env_universal_common.cpp: don't bother trying nonexistent path 2015-11-28 14:34:27 +08:00