Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic sprintf error messages, only when needed #46

Open
rurban opened this issue Feb 7, 2018 · 0 comments
Open

dynamic sprintf error messages, only when needed #46

rurban opened this issue Feb 7, 2018 · 0 comments

Comments

@rurban
Copy link
Owner

rurban commented Feb 7, 2018

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);
@rurban rurban changed the title sprintf error messages dynamic sprintf error messages, only when needed Feb 7, 2018
rurban added a commit that referenced this issue Feb 7, 2018
Safe memory, better error messages, mostly ignored.
See #46.
Applied to strcat_s, strncat_s
rurban added a commit that referenced this issue Feb 7, 2018
Safe memory, better error messages, mostly ignored.
See #46.
Applied to strcat_s, strncat_s
rurban added a commit that referenced this issue Feb 7, 2018
Safe memory, better error messages, mostly ignored.
See #46.
Applied to strcat_s, strncat_s
rurban added a commit that referenced this issue Feb 8, 2018
rurban added a commit that referenced this issue Feb 8, 2018
to be used later overall.
we can now statically append __FUNCTION__ to the msg (which
we always never need), avoiding sprintf.

See #46 which might decide that the memory win of the func prefix
in combined const .cstrings with sprintf will be better.
rurban added a commit that referenced this issue Feb 8, 2018
Safe memory, better error messages, mostly ignored.
See #46.
Applied to strcat_s, strncat_s
rurban added a commit that referenced this issue Feb 9, 2018
to be used later overall.
we can now statically append __FUNCTION__ to the msg (which
we always never need), avoiding sprintf.

See #46 which might decide that the memory win of the func prefix
in combined const .cstrings with sprintf will be better.
rurban added a commit that referenced this issue Feb 10, 2018
to be used later overall.
we can now statically append __FUNCTION__ to the msg (which
we always never need), avoiding sprintf.

See #46 which might decide that the memory win of the func prefix
in combined const .cstrings with sprintf will be better.
rurban added a commit that referenced this issue Feb 26, 2018
to be used later overall.
we can now statically append __FUNCTION__ to the msg (which
we always never need), avoiding sprintf.

See #46 which might decide that the memory win of the func prefix
in combined const .cstrings with sprintf will be better.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant