Commit Graph

28 Commits

Author SHA1 Message Date
Kurtis Rader
509ee64fc9 implement our own assert() function
I recently upgraded the software on my macOS server and was dismayed to
see that cppcheck reported a huge number of format string errors due to
mismatches between the format string and its arguments from calls to
`assert()`. It turns out they are due to the macOS header using `%lu`
for the line number which is obviously wrong since it is using the C
preprocessor `__LINE__` symbol which evaluates to a signed int.

I also noticed that the macOS implementation writes to stdout, rather
than stderr. It also uses `printf()` which can be a problem on some
platforms if the stream is already in wide mode which is the normal case
for fish.

So implement our own `assert()` implementation. This also eliminates
double-negative warnings that we get from some of our calls to
`assert()` on some platforms by oclint.

Also reimplement the `DIE()` macro in terms of our internal
implementation.

Rewrite `assert(0 && msg)` statements to `DIE(msg)` for clarity and to
eliminate oclint warnings about constant expressions.

Fixes #3276, albeit not in the fashion I originally envisioned.
2017-02-14 18:48:27 -08:00
Kurtis Rader
7fc1994339 some trivial lint cleanups 2017-02-13 18:48:59 -08:00
Kurtis Rader
4ffb0adb78 lint cleanups 2017-02-11 21:30:38 -08:00
ridiculousfish
4ac2cfba61 Adopt owning_lock in iothread.cpp 2017-01-29 21:06:46 -08:00
Kurtis Rader
5b6cc5af6d time for another make style-all
Gotta keep the entropy (i.e., disorder) from increasing.
2017-01-26 20:05:46 -08:00
ridiculousfish
1efb81456b Use std::move instead of swap in a few places where it improves clarity 2017-01-26 16:14:50 -08:00
ridiculousfish
a3dbca90d5 g++-friendly 'Rework iothread_perform for void return types'
Allows iothread_perform to work with void return types on both
g++ and clang

This reverts commit 1040b255c7
and reintroduces ac9a0f0dbf
2017-01-26 09:40:17 -08:00
ridiculousfish
1cfbd62266 Enable use of std::function and lambdas in iothread_perform 2017-01-23 11:35:22 -08:00
ridiculousfish
02ddc20c87 Correct signatures of main_thread_request_t's deleted functions 2017-01-23 10:58:38 -08:00
ridiculousfish
e1adc3a6b2 Make iothread's perform_on_main use std::function
This will allow clients to use lambdas instead of having to
define an out-of-line function
2017-01-23 10:37:16 -08:00
ridiculousfish
7a76efa629 Use set_cloexec instead of fcntl directly in iothread.cpp 2017-01-23 09:59:56 -08:00
ridiculousfish
216f7d912a Clean up some of the memory management in iothread.cpp
Store requests directly on the queue, instead of via a heap allocation
2017-01-23 09:56:02 -08:00
ridiculousfish
d373f1fc1d Lower-snake-case for MainThreadRequest_t and SpawnRequest_t
Matches style of rest of the project
2017-01-23 09:34:30 -08:00
Kurtis Rader
2e9a349dd0 normalize use of stdio functions taking a stream
We should never use stdio functions that use stdout implicitly. Saving a
few characters isn't worth the inconsistency. Too, using the forms such
as `fwprintf()` which take an explicit stream makes it easier to find
the places we write to stdout versus stderr.

Fixes #3728
2017-01-13 20:48:55 -08:00
Fabian Homborg
177e06808c Replace all printf invocations with wprintf
Remember, GNU doesn't allow mixing narrow and wide IO.
2017-01-07 14:05:42 +01: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
b7d910a941 lint: long variable name 2016-11-03 16:19:41 -07:00
Kurtis Rader
6bef7b7be9 lint: constant if expression 2016-10-29 19:01:19 -07:00
Kurtis Rader
21521b2953 lint: too few branches in switch statement
Someone was way too enamored of the `switch` statement. Using it in
places where a simple `if...else if...else` was clearer and shorter.
2016-10-22 21:01:27 -07:00
Kurtis Rader
c07c98ac05 eliminate many "unused parameter" warnings
Partially addresses issue #3430.
2016-10-09 14:38:26 -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
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
David Adam
9225b16d12 add (or restore) config.h to all files
The autoconf-generated config.h contains a number of directives which
may alter the behaviour of system headers on certain platforms. Always
include it in every C++ file as the first include.

Closes #2993.
2016-05-18 22:30:21 +00:00
Kurtis Rader
483b798863 restyle iothread module to match project style
Reduces lint errors from 41 to 26 (-37%). Line count from 444 to 423 (-5%).

Another step in resolving issue #2902.
2016-05-01 21:54:54 -07: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
David Adam
3929e9de0e Merge branch 'master' into iwyu 2015-07-26 10:20:13 +08:00
ridiculousfish
b4f53143b0 Migrate source files into src/ directory
This change moves source files into a src/ directory,
and puts object files into an obj/ directory. The Makefile
and xcode project are updated accordingly.

Fixes #1866
2015-07-24 00:59:27 -07:00