haproxy/include/common
Willy Tarreau 071d4b31ff MINOR: compiler: add a new macro ALREADY_CHECKED()
This macro may be used to block constant propagation that lets the compiler
detect a possible NULL dereference on a variable resulting from an explicit
assignment in an impossible check. Sometimes a function is called which does
safety checks and returns NULL if safe conditions are not met. The place
where it's called cannot hit this condition and dereferencing the pointer
without first checking it will make the compiler emit a warning about a
"potential null pointer dereference" which is hard to work around. This
macro "washes" the pointer and prevents the compiler from emitting tests
branching to undefined instructions. It may only be used when the developer
is absolutely certain that the conditions are guaranteed and that the
pointer passed in argument cannot be NULL by design.

A typical use case is a top-level function doing this :

     if (frame->type == HEADERS)
        parse_frame(frame);

Then parse_frame() does this :

    void parse_frame(struct frame *frame)
    {
        const char *frame_hdr;

        frame_hdr = frame_hdr_start(frame);
        if (*frame_hdr == FRAME_HDR_BEGIN)
            process_frame(frame);
    }

and :

    const char *frame_hdr_start(const struct frame *frame)
    {
        if (frame->type == HEADERS)
            return frame->data;
        else
            return NULL;
    }

Above parse_frame() is only called for frame->type == HEADERS so it will
never get a NULL in return from frame_hdr_start(). Thus it's always safe
to dereference *frame_hdr since the check was already performed above.
It's then safe to address it this way instead of inventing dummy error
code paths that may create real bugs :

    void parse_frame(struct frame *frame)
    {
        const char *frame_hdr;

        frame_hdr = frame_hdr_start(frame);
        ALREADY_CHECKED(frame_hdr);
        if (*frame_hdr == FRAME_HDR_BEGIN)
            process_frame(frame);
    }
2018-12-08 15:27:03 +01:00
..
accept4.h
base64.h
buf.h BUILD: buffers: buf.h requires unistd to get ssize_t on libmusl 2018-11-26 19:49:21 +01:00
buffer.h MEDIUM: memory: make the pool cache an array and not a thread_local 2018-11-26 19:50:32 +01:00
cfgparse.h MINOR: initcall: use initcalls for section parsers 2018-11-26 19:50:32 +01:00
chunk.h CLEANUP: Fix typo in the chunk headers file 2018-12-02 18:37:56 +01:00
compat.h MINOR: compat: automatically detect support for crypt_r() 2018-10-29 19:14:14 +01:00
compiler.h MINOR: compiler: add a new macro ALREADY_CHECKED() 2018-12-08 15:27:03 +01:00
config.h MINOR: fd: centralize poll timeout computation in compute_poll_timeout() 2018-10-17 19:59:43 +02:00
debug.h
defaults.h MEDIUM: ssl: add support for ciphersuites option for TLSv1.3 2018-10-08 19:20:13 +02:00
epoll.h
errors.h
h2.h MINOR: h2: add new functions to produce an HTX message from an H2 response 2018-12-02 13:30:17 +01:00
hash.h MINOR: hash: add new function hash_crc32c 2018-03-21 05:04:01 +01:00
hathreads.h MINOR: threads: add new macros to declare self-initializing locks 2018-11-26 19:50:32 +01:00
hpack-dec.h MAJOR: chunks: replace struct chunk with struct buffer 2018-07-19 16:23:43 +02:00
hpack-enc.h MAJOR: chunks: replace struct chunk with struct buffer 2018-07-19 16:23:43 +02:00
hpack-huff.h MINOR: hpack: implement the HPACK Huffman table decoder 2017-10-31 18:03:24 +01:00
hpack-tbl.h BUG/CRITICAL: hpack: fix improper sign check on the header index value 2018-09-20 11:45:56 +02:00
http-hdr.h MINOR: http: add http_hdr_del() to remove a header from a list 2018-09-14 17:40:35 +02:00
http.h MEDIUM: proto_htx: Convert all HTTP error messages into HTX 2018-12-01 17:37:27 +01:00
initcall.h MINOR: initcall: introduce a way to register init functions to call at boot 2018-11-26 19:50:32 +01:00
ist.h MEDIUM: ist: use local conversion arrays to case conversion 2018-12-07 13:25:59 +01:00
istbuf.h MINOR: buffer: rename the data length member to '->data' 2018-07-19 16:23:43 +02:00
memory.h MEDIUM: memory: make the pool cache an array and not a thread_local 2018-11-26 19:50:32 +01:00
mini-clist.h CLEANUP: Fix a typo in the mini-clist header 2018-12-02 18:38:15 +01:00
namespace.h MINOR: namespaces: don't build namespace.c if disabled 2018-11-12 19:15:15 +01:00
net_helper.h
regex.h MINOR: threads/regex: Change Regex trash buffer into a thread local variable 2017-10-31 13:58:31 +01:00
splice.h
standard.h CLEANUP: Fix typos in the standard subsystem 2018-11-18 22:26:42 +01:00
syscall.h
template.h
ticks.h
time.h MINOR: poller: move the call of tv_update_date() back to the pollers 2018-11-22 18:57:37 +01:00
tools.h
uri_auth.h
version.h [RELEASE] Released version 1.9-dev0 2017-11-26 19:50:17 +01:00
xref.h MEDIUM: threads/xref: Convert xref function to a thread safe model 2017-10-31 13:58:32 +01:00