Skip to content

dynamic sprintf error messages, only when needed #46

@rurban

Description

@rurban

Most error messages can be ignored, as they are only passed to the current constraint_handler, which is by default ignoring it. Only with --enable-debug the ignore_handler uses it.

Add a global bool has_safe_str_constraint_handler and skip processing the err_msg when it is empty.
With a handler create a new message with more info and more common strings, skipping the __FUNCTION__ prefix. This saves a lot of .cstring space, and we can print some wrong sizes.
The handler is only invoked in the error case.

Test if it's really worth.

/* has_safe_str_constraint_handler check mandatory on DEBUG */
#ifndef DEBUG
# define HAS_SAFE_STR_CONSTRAINT_HANDLER has_safe_str_constraint_handler
#else
# define HAS_SAFE_STR_CONSTRAINT_HANDLER 1
#endif

                if (HAS_SAFE_STR_CONSTRAINT_HANDLER)
                    sprintf(msg, "%s: overlapping objects", __FUNCTION__);
                handle_error(orig_dest, orig_dmax, msg, ESOVRLP);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions