From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=zZTSsn8IVXYpcoGa+QgNztDwnajf6JuGOdyVtwy4+qM=; b=EzVaqRE4ejDHwzE6j66BDDpM4vVKELiY6RpTD3iGlkH3w8MamwrjKU7bytMvfZJI9+ 7AX7WBIwxvJLCzyaWxDoIvmmQ2EW8J2vyDdIqCM4evaVPA+iqizNcy2F8ITb84giNGrh msO/XSGcrX3nPjWnv0/JR4kjXBlGpgYTVOABWH/ZsK0Ln3lNtye+wv4QpssY+I44fWqy 9sIuvJKK/LmFYg46KVSAcNp8hEFu89sTCp7OpXuAwbtucDbwVcpsfy+s0R5CcrqTYl5D 2c97mUIScfmNoH9Dfk4KsxKl50PZ54sqx8Re5QBf+l69dt6LWhKF3S/kibjvCXV/wpdl pdbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=zZTSsn8IVXYpcoGa+QgNztDwnajf6JuGOdyVtwy4+qM=; b=Cgkg5kDOCSFuKHSZA/fQ+5OkbA9+Ki0/8c2NAMyc5qQLizrnoLhTlOUYw7plvNlomg 2Ur5HSXXB/tM1WOCyhe472osKwiUsBjZctmMTgvbuh9/LIEmhBym35rzzBwFVsNPEPGS FWZK1Zz5F7sSAQqP4eVDGV0tSMpBJF047kIj0RDmDvnOokOx7uEO69WvyTv2h4HWzj+L MIxvXuXQ0+vZ6ZRFW5Cs4+PskFpcGtZ016CwC3BGrHTl6vh/DhoYMHqqNOZ8T5m9jRx5 qv1XLgP/PqBsFBJDQO5PLTycQgcgAjeCXI3jTCovuTFEQS/2rE7any6LKm7yaxAkpJx/ kLiQ== X-Gm-Message-State: ALKqPwdgefJ6FbGz1fV5iLyIG5KoUDKBGBh3Hkg7Pa9B8RpplJ549rE3 tQGt2/C1lKm4+D8XggfVFPVwO6GWdJc= X-Google-Smtp-Source: ADUXVKLBVz5TZ6PrQPC0IOyZNnAHrBeBaX6eLX9sMcspQKuCAQ1/QXx+wrZBNLX70K7OvMwe7bTiwQ== X-Received: by 2002:adf:e987:: with SMTP id h7-v6mr4422537wrm.102.1527753815304; 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) From: David Marchand To: dev@dpdk.org Date: Thu, 31 May 2018 10:03:27 +0200 Message-Id: <1527753808-19409-1-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH 1/2] log: remove useless intermediate buffer X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2018 08:03:36 -0000 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