Systemd/src/libsystemd-terminal
David Herrmann 44dd2c6e86 util: introduce negative_errno()
Imagine a constructor like this:

        int object_new(void **out) {
                void *my_object;
                int r;

                ...
                r = ioctl(...);
                if (r < 0)
                        return -errno;
                ...

                *out = my_object;
                return 0;
        }

We have a lot of those in systemd. If you now call those, gcc might inline
the call and optimize it. However, gcc cannot know that "errno" is
negative if "r" is. Therefore, a caller like this will produce warnings:

        r = object_new(&obj);
        if (r < 0)
                return r;

        obj->xyz = "foobar";

In case the ioctl in the constructor fails, gcc might assume "errno" is 0
and thus the error-handling is not triggered. Therefore, "obj" is
uninitialized, but accessed. Gcc will warn about that.

The new negative_errno() helper can be used to mitigate those warnings.
The helper is guaranteed to return a negative integer. Furthermore, it
spills out runtime warnings if "errno" is non-negative.

Instead of returning "-errno", you can use:
        return negative_errno();

gcc will no longer assume that this can return >=0, thus, it will not warn
about it.

Use this new helper in libsystemd-terminal to fix some grdev-drm warnings.
2014-11-04 08:27:31 +01:00
..
evcat.c terminal/idev: don't remove consumed-mods from kbd-matches 2014-10-05 18:02:28 +02:00
grdev-drm.c util: introduce negative_errno() 2014-11-04 08:27:31 +01:00
grdev-internal.h terminal: fix spelling mistake 2014-09-23 09:22:33 -04:00
grdev.c terminal/grdev: allow arbitrary fb-age contexts 2014-10-03 15:57:00 +02:00
grdev.h terminal/grdev: allow arbitrary fb-age contexts 2014-10-03 15:57:00 +02:00
idev-evdev.c terminal: make evdev logind-matches per session 2014-09-22 18:14:44 +02:00
idev-internal.h terminal: make evdev logind-matches per session 2014-09-22 18:14:44 +02:00
idev-keyboard.c terminal/idev: don't map XKB_KEY_NoSymbol as ASCII 0 2014-10-03 15:57:00 +02:00
idev.c terminal: make evdev logind-matches per session 2014-09-22 18:14:44 +02:00
idev.h terminal/idev: don't remove consumed-mods from kbd-matches 2014-10-05 18:02:28 +02:00
modeset.c util: unify how we see srand() 2014-10-30 15:35:37 +01:00
subterm.c terminal/subterm: leave bold-light conversion to parent 2014-10-05 15:48:32 +02:00
sysview-internal.h terminal: add sysview_seat_switch_to() 2014-09-29 15:37:31 +02:00
sysview.c terminal: add helper to retrieve the seat of a session 2014-09-29 15:37:32 +02:00
sysview.h terminal: add helper to retrieve the seat of a session 2014-09-29 15:37:32 +02:00
term-charset.c terminal: add parser state-machine 2014-07-18 12:53:41 +02:00
term-internal.h terminal/screen: add support for alternate screen buffers 2014-10-05 15:26:54 +02:00
term-page.c Fix a few more typos 2014-08-30 13:46:07 -04:00
term-parser.c terminal/screen: perform bold->light conversion only on foreground 2014-10-05 15:49:26 +02:00
term-screen.c terminal: log unsupported ANSI or DEC mode changes 2014-10-16 14:43:57 +02:00
term-wcwidth.c terminal: avoid warning about signed-unsigned comparison 2014-08-03 23:53:49 -04:00
term.h terminal/screen: adjust screen age only on update 2014-10-03 15:57:00 +02:00
test-term-page.c Fix a few more typos 2014-08-30 13:46:07 -04:00
test-term-parser.c terminal: make utf8 decoder return length 2014-10-03 15:57:00 +02:00
test-unifont.c terminal: move unifont-internal.h to unifont.h 2014-10-02 08:40:43 +02:00
unifont-def.h terminal: move unifont-map to datadir 2014-10-02 08:40:43 +02:00
unifont-glyph-array.bin terminal: add unifont font-handling 2014-07-18 17:45:33 +02:00
unifont.c terminal/unifont: add built-in fallback glyph 2014-10-03 15:57:00 +02:00
unifont.h terminal/unifont: add built-in fallback glyph 2014-10-03 15:57:00 +02:00
unifont.hex terminal: add unifont font-handling 2014-07-18 17:45:33 +02:00