From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id 83582B11F for ; Tue, 24 Jun 2014 20:15:20 +0200 (CEST) Received: by mail-pa0-f50.google.com with SMTP id bj1so577474pad.9 for ; Tue, 24 Jun 2014 11:15:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=jv7mHFK4pEjpjLRsbOzxqEw/8s2rXJ1r5DVMktrd41Q=; b=maB9bVKg1urtptg9vrKMjAZ/aTJwnXqTNRsTzrxWHUvxrc/1iUm0fdtWFQwGNXl0DW xB/q4lOjH5C+v5b2Kxyh9Oj4HWSKeup219xBWXL9zkvysGuXycsCafi28z4j7U0VwUJb zEQmjBSHCkDfTq2akys52eImhHqslaydQthzo/YoCqTOSAJ65AnKoyb4Bfql7l+zAwdl 2/Uvd+S5VANG+SOOiPnHOKyLg1HCwEwmPfpcWYP70bpF3nJwkh5b+z5r593oUj6BhLdU FYtnyv1h6O7g1GD2QGciclWVDwAkKbLwoiR+12yC7o/g6vSgkcfIEBYCNN6Kg1kL7kKa Odww== X-Gm-Message-State: ALoCoQma9EeHb5EHahvgAo/SN3tvLmUo7iDRcaJ0u0rojWaN1LBpoKkCME5wnmrkbqdBYWEQz/z9 X-Received: by 10.66.141.76 with SMTP id rm12mr3995949pab.138.1403633736973; Tue, 24 Jun 2014 11:15:36 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id f2sm4873683pat.11.2014.06.24.11.15.36 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 24 Jun 2014 11:15:36 -0700 (PDT) Date: Tue, 24 Jun 2014 11:14:38 -0700 From: Stephen Hemminger To: Stephen Hemminger Message-ID: <20140624111438.11944cf0@nehalam.linuxnetplumber.net> In-Reply-To: <20140624111333.721633f7@nehalam.linuxnetplumber.net> References: <20140624111333.721633f7@nehalam.linuxnetplumber.net> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 1/2 v2] fix incorrect snprintf args X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jun 2014 18:15:21 -0000 Now that snprintf is used, Gcc finds more uses of unsafe arguments. Fix where found. Some of these may have already been fixed by other patches on the mailing list. Signed-off-by: Stephen Hemminger --- v2 - no changes to this part --- a/lib/librte_kni/rte_kni.c 2014-06-24 08:48:55.758031238 -0700 +++ b/lib/librte_kni/rte_kni.c 2014-06-24 08:48:55.754031210 -0700 @@ -158,7 +158,7 @@ rte_kni_alloc(struct rte_mempool *pktmbu } } - snprintf(intf_name, RTE_KNI_NAMESIZE, conf->name); + snprintf(intf_name, RTE_KNI_NAMESIZE, "%s", conf->name); snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "KNI_INFO_%s", intf_name); mz = kni_memzone_reserve(mz_name, sizeof(struct rte_kni), SOCKET_ID_ANY, 0); @@ -184,8 +184,8 @@ rte_kni_alloc(struct rte_mempool *pktmbu dev_info.group_id = conf->group_id; dev_info.mbuf_size = conf->mbuf_size; - snprintf(ctx->name, RTE_KNI_NAMESIZE, intf_name); - snprintf(dev_info.name, RTE_KNI_NAMESIZE, intf_name); + snprintf(ctx->name, RTE_KNI_NAMESIZE, "%s", intf_name); + snprintf(dev_info.name, RTE_KNI_NAMESIZE, "%s", intf_name); RTE_LOG(INFO, KNI, "pci: %02x:%02x:%02x \t %02x:%02x\n", dev_info.bus, dev_info.devid, dev_info.function, @@ -291,7 +291,7 @@ rte_kni_release(struct rte_kni *kni) if (!kni || !kni->in_use) return -1; - snprintf(dev_info.name, sizeof(dev_info.name), kni->name); + snprintf(dev_info.name, sizeof(dev_info.name), "%s", kni->name); if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) { RTE_LOG(ERR, KNI, "Fail to release kni device\n"); return -1; --- a/app/test/test_cmdline_etheraddr.c 2014-06-24 08:35:31.820146456 -0700 +++ b/app/test/test_cmdline_etheraddr.c 2014-06-24 08:54:35.396486084 -0700 @@ -147,7 +147,7 @@ test_parse_etheraddr_invalid_param(void) /* copy string to buffer */ snprintf(buf, sizeof(buf), "%s", - ether_addr_valid_strs[0]); + ether_addr_valid_strs[0].str); ret = cmdline_parse_etheraddr(NULL, buf, NULL); if (ret == -1) { --- a/app/test/test_eal_flags.c 2014-06-24 08:35:31.820146456 -0700 +++ b/app/test/test_eal_flags.c 2014-06-24 08:53:16.623916364 -0700 @@ -268,7 +268,7 @@ get_current_prefix(char * prefix, int si /* copy string all the way from second char up to start of _config */ snprintf(prefix, size, "%.*s", - strnlen(buf, sizeof(buf)) - sizeof("_config"), &buf[1]); + (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")), &buf[1]); return prefix; } --- a/app/test/test_mp_secondary.c 2014-06-24 08:35:31.820146456 -0700 +++ b/app/test/test_mp_secondary.c 2014-06-24 08:50:27.706700011 -0700 @@ -103,7 +103,7 @@ get_current_prefix(char * prefix, int si /* copy string all the way from second char up to start of _config */ snprintf(prefix, size, "%.*s", - strnlen(buf, sizeof(buf)) - sizeof("_config"), &buf[1]); + (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")), &buf[1]); return prefix; }