X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcontext.cpp;h=14763c00d3b83beb680861304a4982bfa287fb9f;hb=HEAD;hp=a4111ad9002e9a29fcd073b4b4c6f93b41041040;hpb=64803277bbdbe0a943360d918298a48157d9da55;p=lttng-tools.git diff --git a/src/common/context.cpp b/src/common/context.cpp index a4111ad90..14763c00d 100644 --- a/src/common/context.cpp +++ b/src/common/context.cpp @@ -6,16 +6,17 @@ */ #include "context.hpp" -#include -#include + #include #include -int parse_application_context(const char *str, char **out_provider_name, - char **out_ctx_name) +#include +#include + +int parse_application_context(const char *str, char **out_provider_name, char **out_ctx_name) { const char app_ctx_prefix[] = "$app."; - char *provider_name = NULL, *ctx_name = NULL; + char *provider_name = nullptr, *ctx_name = nullptr; size_t i, len, colon_pos = 0, provider_name_len, ctx_name_len; if (!str || !out_provider_name || !out_ctx_name) { @@ -28,7 +29,7 @@ int parse_application_context(const char *str, char **out_provider_name, } /* String starts with $app. */ - if (strncmp(str, app_ctx_prefix, sizeof(app_ctx_prefix) - 1)) { + if (strncmp(str, app_ctx_prefix, sizeof(app_ctx_prefix) - 1) != 0) { goto not_found; } @@ -46,8 +47,7 @@ int parse_application_context(const char *str, char **out_provider_name, * No colon found or no ctx name ("$app.provider:") or no provider name * given ("$app.:..."), which is invalid. */ - if (!colon_pos || colon_pos == len || - colon_pos == sizeof(app_ctx_prefix)) { + if (!colon_pos || colon_pos == len || colon_pos == sizeof(app_ctx_prefix)) { goto not_found; } @@ -57,8 +57,7 @@ int parse_application_context(const char *str, char **out_provider_name, PERROR("malloc provider_name"); goto not_found; } - strncpy(provider_name, str + sizeof(app_ctx_prefix) - 1, - provider_name_len - 1); + strncpy(provider_name, str + sizeof(app_ctx_prefix) - 1, provider_name_len - 1); ctx_name_len = len - colon_pos; ctx_name = calloc(ctx_name_len); @@ -76,4 +75,3 @@ not_found: free(ctx_name); return -1; } -