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 CB67E42C04; Thu, 1 Jun 2023 17:01:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1EE142D3D; Thu, 1 Jun 2023 17:01:17 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 495DE42D3A for ; Thu, 1 Jun 2023 17:01:17 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1b041cceb16so8048995ad.2 for ; Thu, 01 Jun 2023 08:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1685631676; x=1688223676; 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=3JuhadsjfflQsneHaARKKs7cNuYBKeWlaNdhUAcHkpo=; b=m+t1s4hyAr96btn/BFl3aqUcR8ATZc20UOCYSDXgsAinqa5g8CCz4zahZnAWuWhOPY d41nLxBD6uO9JubjrVStvIgvPQcbWOdihuc44Sf++0opLpBVtonsxEPxsbk1YsxPKwLm AVllHLFnUhII540/neIGjtpEELr/XmvsyYOBThgAtxhN/9zud6m1aPSdy0sP/zoKppyF 4jCzz//UwT8ixZUwlTIA1r56xXXqHNmsDolw5YCTSIxiDxYuIap5WfUF0A8phZAit2kK EhGYpLyF8MHd6rm40RQhrlilbHikDof/4J0AT2GxoqSAm2s2R+QLp8OP7JmFaAnL+ZTB 6eow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631676; x=1688223676; 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=3JuhadsjfflQsneHaARKKs7cNuYBKeWlaNdhUAcHkpo=; b=apdlacn4VvYfbvhWWdRP0cmPFUbiuLBgG4opzw4LSURfhjgGblLR/q76bnLN/y8NKl fkkrB/zxcXBgWjbjPCEkUCEiyWAWe1RYn0gzIjJ3BJtnPvsf/yZ5tfHcPePl66puNrAm zG83JUBFy6tNKG0Rfw8b6EDjKWHwTP5Fp7s9d9fT90ReG/59SdqEgGyV11qq9K3TvlkV G8Sfz9ulfGQXLpy+tdWr2ids7V+84zkpVPuJQfL8kVoUOSbvnPzTahbKb5RCWgih7fG9 ueMuyTCqZkZ0jrGA0U6ivYwFSvePsdOuLSd/FPlXY6loxYkO5uBtTNZIbSuDpOnLURBf ef6w== X-Gm-Message-State: AC+VfDyewH2orrPhoPQpl3XTocpiFxo6j7bGiYrbAecjgi409hbl4x1i 9Ps83dxpNh0ybvRWCZecJDhmIf7OHhhvSTlz2OBjZw== X-Google-Smtp-Source: ACHHUZ5CRbnBmT3ZND6cy7YOS9VW5kVmmb/SV76j4xViZB2jfByQQEpYkIzC1X3ccuFdenT+wdG57Q== X-Received: by 2002:a17:903:2284:b0:1b0:45e2:ef38 with SMTP id b4-20020a170903228400b001b045e2ef38mr10320049plh.26.1685631676174; Thu, 01 Jun 2023 08:01:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 08:01:15 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Nicolas Chautru , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH 03/25] lib: use strlcpy instead of snprintf Date: Thu, 1 Jun 2023 08:00:44 -0700 Message-Id: <20230601150106.18375-4-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 Replace snprintf with strlcpy where possible. Signed-off-by: Stephen Hemminger --- lib/bbdev/rte_bbdev.c | 2 +- lib/ethdev/sff_8636.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c index 581509b5a213..7cc126a0e7be 100644 --- a/lib/bbdev/rte_bbdev.c +++ b/lib/bbdev/rte_bbdev.c @@ -212,7 +212,7 @@ rte_bbdev_allocate(const char *name) bbdev->data->dev_id = dev_id; bbdev->state = RTE_BBDEV_INITIALIZED; - ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name); + ret = strlcpy(bbdev->data->name, name, RTE_BBDEV_NAME_MAX_LEN); if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) { rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name); return NULL; diff --git a/lib/ethdev/sff_8636.c b/lib/ethdev/sff_8636.c index 6b65f47efedf..a623e0d065d8 100644 --- a/lib/ethdev/sff_8636.c +++ b/lib/ethdev/sff_8636.c @@ -203,16 +203,19 @@ static void sff_8636_show_ext_identifier(const uint8_t *data, struct rte_tel_dat switch (data[SFF_8636_EXT_ID_OFFSET] & SFF_8636_EXT_ID_EPWR_CLASS_MASK) { case SFF_8636_EXT_ID_PWR_CLASS_LEGACY: - snprintf(val_string, sizeof(val_string), "%s", ""); + strlcpy(val_string, "", sizeof(val_string)); break; case SFF_8636_EXT_ID_PWR_CLASS_5: - snprintf(val_string, sizeof(val_string), "%s", "4.0W max. Power consumption, "); + strlcpy(val_string, "4.0W max. Power consumption, ", + sizeof(val_string)); break; case SFF_8636_EXT_ID_PWR_CLASS_6: - snprintf(val_string, sizeof(val_string), "%s", "4.5W max. Power consumption, "); + strlcpy(val_string, "4.5W max. Power consumption, ", + sizeof(val_string)); break; case SFF_8636_EXT_ID_PWR_CLASS_7: - snprintf(val_string, sizeof(val_string), "%s", "5.0W max. Power consumption, "); + strlcpy(val_string, "5.0W max. Power consumption, ", + sizeof(val_string)); break; } -- 2.39.2