From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5FC5D42C04; Thu, 1 Jun 2023 17:02:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3842C42D59; Thu, 1 Jun 2023 17:01:23 +0200 (CEST) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id AAF2742D55 for ; Thu, 1 Jun 2023 17:01:21 +0200 (CEST) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-64d5f65a2f7so649384b3a.1 for ; Thu, 01 Jun 2023 08:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1685631680; x=1688223680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9BATqt2tO/9/EDDw5Lf9l06MYHtgzXoYUTBgmOoOGsQ=; b=l7O3bW6J9Qr3pA07CJK4/X6m22E7gBxBLtFvOFJj//PW96TQrhj+fij/jGbtyZB+VK ufpzIvzZcy9otHukFW+1QEucYui5+6k/9r/oIqWmTt6J6dWhJzGlt/kSNblWMv1z/j3t uJfwYXhkJg0Mi2pyMdLCNKO6H6FbyZ9lXAXRIvQ82OW6JVruZmF3f7yM1mPPJVkd0z2t ZsI2XAnVQCrED0uu7msTdoWGLP/KTrQf4ErHaZuS3xRnX+s9ocqn98TDWZvg+9mVb3SM XvF6l4pQEVEMlaPD8Y/WAAawsPUIeuzTd4sqblk8gZgFLvd9elD1qeHhn1YSCLFvQO4j 3lNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631680; x=1688223680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9BATqt2tO/9/EDDw5Lf9l06MYHtgzXoYUTBgmOoOGsQ=; b=QG/wMYBHVQUDENMSqs5FLF4sWie94jlRjJ8SSdLsjwllzqSDdcUMCqZyzFyfOs5lwe e65Rte0JthcM7ZfZnb3QygDGiFRNqu9j4kZrgsYZpkKayu1udODdN1SCE93DSga6ZSy7 D6zJctS92qW5L5ju1D8B4VRuihDEGDUhYMhCuihWSTLpB6bU8dPm78V10n2YfD0CkNDr +3x5dt95W9+kZvN2bY+IhD7mU4XYsoH/nriRP9P7Zj/2CDpe6/5PwzTCNAULg6/O/LIK +xUi55YsfqWV6X2Qsxq/6QLG2zOfQVhL6IrioQV3hq17p4WAMDDy6/LQKOHNRIRp4WpF eWsg== X-Gm-Message-State: AC+VfDypQtWC0DNopIxZdqapqfenYNRF1xKlpLb2MBYOsubDzp12TJhI p82Lp2K7oHMm8NyKdnHBnLoKtPHxmUwckmC5vKt0lA== X-Google-Smtp-Source: ACHHUZ4Mff9MjrB28hQIgHP6Rc4PeUPTmpgx5itDWL2OfjH7IbuHaYp8JlVi7cnFmow3pNH9ohpP8A== X-Received: by 2002:a17:902:d50c:b0:1b0:663e:4b3f with SMTP id b12-20020a170902d50c00b001b0663e4b3fmr5738915plg.37.1685631680543; Thu, 01 Jun 2023 08:01:20 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id ij9-20020a170902ab4900b001ac40488620sm3661955plb.92.2023.06.01.08.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 08:01:19 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH 06/25] common/mlx5: replace snprintf with strlcpy Date: Thu, 1 Jun 2023 08:00:47 -0700 Message-Id: <20230601150106.18375-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230601150106.18375-1-stephen@networkplumber.org> References: <20230601150106.18375-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Suggested by devtools/cocci/strlcpy-with-header.cocci Signed-off-by: Stephen Hemminger --- drivers/common/mlx5/linux/mlx5_common_os.c | 2 +- drivers/common/mlx5/mlx5_common_utils.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index aafff60eeb38..c4ceeccf3825 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -897,7 +897,7 @@ mlx5_get_device_guid(const struct rte_pci_addr *dev, uint8_t *guid, size_t len) } } while (strchr(ptr->d_name, '.') || strchr(ptr->d_name, '_') || strchr(ptr->d_name, 'v')); - snprintf(cur_ifname, sizeof(cur_ifname), "%s", ptr->d_name); + strlcpy(cur_ifname, ptr->d_name, sizeof(cur_ifname)); closedir(dir); snprintf(tmp + strlen(tmp), sizeof(tmp) - strlen(tmp), "/%s/phys_switch_id", cur_ifname); diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c index e69d06878c2e..3e809b409854 100644 --- a/drivers/common/mlx5/mlx5_common_utils.c +++ b/drivers/common/mlx5/mlx5_common_utils.c @@ -49,8 +49,7 @@ mlx5_list_create(const char *name, void *ctx, bool lcores_share, if (!list) return NULL; if (name) - snprintf(list->l_const.name, - sizeof(list->l_const.name), "%s", name); + strlcpy(list->l_const.name, name, sizeof(list->l_const.name)); list->l_const.ctx = ctx; list->l_const.lcores_share = lcores_share; list->l_const.cb_create = cb_create; @@ -422,7 +421,7 @@ mlx5_hlist_create(const char *name, uint32_t size, bool direct_key, return NULL; } if (name) - snprintf(h->l_const.name, sizeof(h->l_const.name), "%s", name); + strlcpy(h->l_const.name, name, sizeof(h->l_const.name)); h->l_const.ctx = ctx; h->l_const.lcores_share = lcores_share; h->l_const.cb_create = cb_create; -- 2.39.2