The LTTng client currently uses sprintf with format strings
that don't contain a format specifier.
Users have reported concerns for the scalability and performance
of the LTTng UI because of this overkill use of sprintf instead
of strcpy which, presumably, could be inlined by the compiler.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
int count;
size_t i;
const char * const exclusion_fmt = " [exclusions: ";
+ const size_t exclusion_fmt_len = strlen(exclusion_fmt);
exclusion_count = lttng_event_get_exclusion_name_count(event);
if (exclusion_count < 0) {
*/
exclusion_msg = malloc(exclusion_count +
exclusion_count * LTTNG_SYMBOL_NAME_LEN +
- strlen(exclusion_fmt) + 1);
+ exclusion_fmt_len + 1);
if (!exclusion_msg) {
goto end;
}
- at = exclusion_msg;
- count = sprintf(at, exclusion_fmt);
- at += count;
-
+ at = strcpy(exclusion_msg, exclusion_fmt) + exclusion_fmt_len;
for (i = 0; i < exclusion_count; ++i) {
const char *name;
}
/* This also puts a final '\0' at the end of exclusion_msg */
- sprintf(at, "]");
+ strcpy(at, "]");
end:
return exclusion_msg;