xdata/xodtemplate: Count escalations even when using precached objects

Otherwise we'll crash out while reading config from a precached object
file contiaining escalations.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Reorganize and sort-of-simplify base/workers.c

Reorganize because we want the simple file-scoped functions up top,
where pretty much everyone can use them.
Sort-of-simplify because we now have a 1-1 relation (well, almost)
between job creation and destruction, instead of building a job all
over the place and then trying to destroy it in a single function.

This fixes a pretty rare sigsegv problem which could earlier happen
during shutdown if we failed to send one or more jobs to the worker.

The change is larger than it has to be because the bug is extremely
hard to test for, so defensive coding is necessary to avoid triggering
it in the future. It also paves the way for part two of this series,
which will sanitize the worker process management somewhat, since
that's currently somewhat broken for specialized workers.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Fix and tidy up removal of disconnected workers

This simplifies removal a bit, making it an explicit part of the
lifetime of a worker and allows us to reduce the complexity of the parts
of the code that deals with shutdowns/disconnects.

Signed-off-by: Anton Lofgren <alofgren@op5.com>
base/workers: Use the right job_id when reporting missing jobs

Previously we used an initialized-but-unused variable, which meant
we always printed "Job with id '-1' doesn't exist on <worker>.".
With this patch, we fix it so the job-id that actually came back
is used instead, which makes much more sense.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/t-utils: Fix compiler warning about string literals

These actually need fixing, since test strings and names may well
contain format string characters, which would mean we'd get
garbage in the output. Let's avoid that, as noone likes garbage.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/t-utils: Add missing prototype for t_reset()

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/test-iobroker: Properly initialize addrlen for accept(2)

strace gives random warnings otherwise, rightly indicating that
we've done something stupid.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/test-runcmd: Add missing initializers

Since we improved on the testsuite somewhat, the sentinel in the
test-data struct was a tad malformed. This patch corrects it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/test-nsutils: Squelch compiler warnings

Harmless ones, but it's still good to get them to shut up so the
real warnings become more visible.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/fanout: Add fanout_get()

add and remove could do the trick, but it would be unnecessarily
cumbersome to handle reading some data from the fanout table when
we use it like that, so add the 'get' function as well.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Remove unused function parameters

Some functions take parameters that are never used, or are only
used for passing to leaf functions which don't use them. This
removes most of the ones I could easily find, but only where it's
safe to do so with regards to API and ABI compatibility, so the
xdata stuff (which isn't publicly exported to modules) and a lot
of initialization and cleanup functions (which modules aren't
supposed to run anyway) are modified. And CGI's, ofcourse.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Janitor patch: Remove trailing newlines in files

Silly, but helpful when counting codelines.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Janitor patch: Remove trailing whitespace from lines

Editors should remove them when saving, and most do, but that
tends to clutter up the diff output, so let's purge the evilness
in a single commit instead.

We only touch .c and .h files though, since whitespace has
semantic meaning for Makefiles and is useful to be able to add
to test-files and suchlike.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Stop shadowing variables, types and functions

It's most often done with variables that are of the same type,
which means renaming them will cause some variable accesses to
access the global variable while others may use the local one.
Such bugs are generally nearly impossible to track down, since
one has to follow the actual logic to figure out which variable
is intended to be used (after all; The whole point of global vars
is that they can be used from anywhere).

Detected with -Wshadow option to gcc.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Declare const strings as const

This allows the compiler to optimize things better. Function calls
in particular benefit hugely from this.

As a nice sideeffect, we get a neat hint about which functions
have a tendency to modify their arguments and which don't.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/pqueue: Hide internal test-functions by default

They're unused and should really only be built in case one does
detailed analysis of the pqueue library, so let's avoid it if at
all possible.

The fact that we also hide some compiler warnings this way is a
neat added bonus.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/kvvec: Fix return type and prototype for kvvec_capacity()

Signed-off-by: Andreas Ericsson <ae@op5.se>
common/objects.c: Make opts2str() and its data core-only

Building for cgi's would otherwise complain that static functions
aren't used. Also, make the data const and static while we're at
it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
libnagios: Fix warnings about signed-vs-unsigned comparisons

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/bitmap: remove dead function "bitmap_minus()"

It was never published and has no users, so remove it.

Signed-off-by: Andreas Ericsson <ae@op5.se>