X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-trace.c;h=0de78da52ab14118f3e7f7213a23afd02fa9a3cd;hb=60cd11786766ebc148b7ec088962dd6e112f8762;hp=aaa16352ae9ae4a585a6157b7c812b811f14ae4c;hpb=5ef271effacb83552f9ea56572c751c2f5a556b6;p=src%2Fapp-framework-binder.git diff --git a/src/afb-trace.c b/src/afb-trace.c index aaa16352..0de78da5 100644 --- a/src/afb-trace.c +++ b/src/afb-trace.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017, 2018 "IoT.bzh" + * Copyright (C) 2016-2019 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +15,8 @@ * limitations under the License. */ +#if WITH_AFB_HOOK && WITH_AFB_TRACE + #define _GNU_SOURCE #include @@ -65,7 +67,7 @@ /* struct for tags */ struct tag { struct tag *next; /* link to the next */ - char tag[1]; /* name of the tag */ + char tag[]; /* name of the tag */ }; /* struct for events */ @@ -148,18 +150,8 @@ static void ctxt_error(char **errors, const char *format, ...) /* timestamp */ static struct json_object *timestamp(const struct afb_hookid *hookid) { -#if JSON_C_MAJOR_VERSION > 0 || JSON_C_MINOR_VERSION >= 12 - char ts[50]; - - snprintf(ts, sizeof ts, "%llu.%06lu", - (long long unsigned)hookid->time.tv_sec, - (long unsigned)((hookid->time.tv_nsec + 500) / 1000)); - - return json_object_new_double_s(0.0f, ts); /* the real value isn't used */ -#else return json_object_new_double((double)hookid->time.tv_sec + (double)hookid->time.tv_nsec * .000000001); -#endif } /* verbosity level name or NULL */ @@ -1081,7 +1073,7 @@ static struct tag *trace_get_tag(struct afb_trace *trace, const char *name, int if (!tag && alloc) { /* creation if needed */ - tag = malloc(sizeof * tag + strlen(name)); + tag = malloc(sizeof * tag + 1 + strlen(name)); if (tag) { strcpy(tag->tag, name); tag->next = trace->tags; @@ -1615,3 +1607,5 @@ int afb_trace_drop(afb_req_t req, struct json_object *args, struct afb_trace *tr free(context.errors); return -1; } + +#endif