Micro-optimisation 23/92023/4
authorMichal Bloch <m.bloch@samsung.com>
Wed, 12 Oct 2016 14:44:55 +0000 (16:44 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 13 Oct 2016 15:33:02 +0000 (17:33 +0200)
Change-Id: I790920282f4d6b4857d3a5b0535e5a9c202c8a70
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/libdlog/log.c
src/shared/logprint.c

index 4c5dd19..6ec03c7 100755 (executable)
@@ -71,7 +71,7 @@ int __write_to_log_null(log_id_t log_id, log_priority prio, const char *tag, con
  */
 static int __config_iteration(const char* key, const char* value)
 {
-       const int prefix_len = strlen("limiter|");
+       const int prefix_len = sizeof("limiter|") - 1;
        char * delimiter_pos;
        char limiter_tag[MAX_CONF_KEY_LEN];
        int limit;
index 2b5217d..539c822 100755 (executable)
@@ -619,11 +619,11 @@ char *log_format_log_line(
        pm = entry->message;
 
        if (prefixSuffixIsHeaderFooter) {
-               strncat(p, prefixBuf, strlen(prefixBuf));
+               strncat(p, prefixBuf, prefixLen);
                p += prefixLen;
                strncat(p, entry->message, entry->messageLen);
                p += entry->messageLen;
-               strncat(p, suffixBuf, strlen(suffixBuf));
+               strncat(p, suffixBuf, suffixLen);
                p += suffixLen;
        } else {
                while (pm < (entry->message + entry->messageLen)) {
@@ -637,11 +637,11 @@ char *log_format_log_line(
                                        && *pm != '\n') pm++;
                        lineLen = pm - lineStart;
 
-                       strncat(p, prefixBuf, strlen(prefixBuf));
+                       strncat(p, prefixBuf, prefixLen);
                        p += prefixLen;
                        strncat(p, lineStart, lineLen);
                        p += lineLen;
-                       strncat(p, suffixBuf, strlen(suffixBuf));
+                       strncat(p, suffixBuf, suffixLen);
                        p += suffixLen;
 
                        if (*pm == '\n')