From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: [PATCH 1/2] log: remove useless intermediate buffer Date: Thu, 31 May 2018 10:03:27 +0200 Message-ID: <1527753808-19409-1-git-send-email-david.marchand@6wind.com> To: dev@dpdk.org Return-path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id E3B1F1B0B for ; Thu, 31 May 2018 10:03:35 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id o12-v6so943422wrm.12 for ; Thu, 31 May 2018 01:03:35 -0700 (PDT) Received: from 6wind.com ([2a01:cb19:142:1800:5db:7039:641c:ad8c]) by smtp.gmail.com with ESMTPSA id 131-v6sm593036wms.34.2018.05.31.01.03.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 01:03:34 -0700 (PDT) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Rather than copy the log message, we can use a precision in the format string given to syslog. Fixes: af75078fece3 ("first public release") Signed-off-by: David Marchand --- lib/librte_eal/linuxapp/eal/eal_log.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_log.c b/lib/librte_eal/linuxapp/eal/eal_log.c index ff14588..9d02ddd 100644 --- a/lib/librte_eal/linuxapp/eal/eal_log.c +++ b/lib/librte_eal/linuxapp/eal/eal_log.c @@ -25,25 +25,14 @@ static ssize_t console_log_write(__attribute__((unused)) void *c, const char *buf, size_t size) { - char copybuf[BUFSIZ + 1]; ssize_t ret; - uint32_t loglevel; /* write on stdout */ ret = fwrite(buf, 1, size, stdout); fflush(stdout); - /* truncate message if too big (should not happen) */ - if (size > BUFSIZ) - size = BUFSIZ; - /* Syslog error levels are from 0 to 7, so subtract 1 to convert */ - loglevel = rte_log_cur_msg_loglevel() - 1; - memcpy(copybuf, buf, size); - copybuf[size] = '\0'; - - /* write on syslog too */ - syslog(loglevel, "%s", copybuf); + syslog(rte_log_cur_msg_loglevel() - 1, "%.*s", (int)size, buf); return ret; } -- 2.7.4