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 ED9CB45CED; Tue, 12 Nov 2024 06:10:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3763402C3; Tue, 12 Nov 2024 06:10:48 +0100 (CET) Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) by mails.dpdk.org (Postfix) with ESMTP id E34DC400D6 for ; Tue, 12 Nov 2024 06:10:46 +0100 (CET) Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-71a4210bcfeso676034a34.1 for ; Mon, 11 Nov 2024 21:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731388246; x=1731993046; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=XBK8ckobAxZQvJh30eWD/F703o7EyqS56XHoi2/cQrY=; b=MZxYcS1cMy0/I3Vr89fQE+6QQcqoA9ofMcNdF0s/wYnbNPC6cDM+W+MDF/kSm5HnJR INDZTzE2qQGi5pNqCugWPGpxpiuXkHTckY43hXVYgyeRnPywqtOq3fLk7NsELn0ylxjh 9+WpKj5YEUUYXvdmEtwK8LTNXA/S7PZQ3wGrhPcSGCHYh9yMG+F3prG6gJTyxyGdGFC2 FIFBUMFXacK7Y2M+uv6VpzfdtaT3YIBwPaZif5VQHzePOoBhH7K+wqENb/MIhOzw5nTG EEq7x9N1XTNvDMg/miKdHQc2xpLgzEuWlfXKIxf7XU8rXetij8y7UtIaCQQkNaRo+qAj 1XTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731388246; x=1731993046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XBK8ckobAxZQvJh30eWD/F703o7EyqS56XHoi2/cQrY=; b=tPWLWgImR3PXu8D2wvkaw3Rv9It9ieHnRFKNOujLd1d4RfDUzfms9iR0XOuFwMI7TN X1gztmCbVuDdqTuFqk73EYPLGvenLgtQn5zpQI9FSzv9tFtFmXDJzKEZJGbOcbfO5vAD p+IB+ya+j3Of+gGEFwWEr3lMJbeDFDndMEO9PcjuAV8XbMh2oq7sQkdgoVHhHlWB6/5W I/dKPWf+859rLzFcqu/OMPDSX93ugJjne1yiH6KIoI3PE8Zq/bwwTpzBw5QpsVxTxswE ifeKpDHAiOYser/Qmi0B7Vqcc2IyRpwVBgHQ91VHKChhZb04PbjBV3g83imhWz3jUr8c iIZw== X-Forwarded-Encrypted: i=1; AJvYcCWtIGVElhpULeykBGgN/fOP9krIMRQf1rjQsT2+e5LXKTu5cYoHlxHJfgLbXA9JmmBWgWc=@dpdk.org X-Gm-Message-State: AOJu0Yw7gVpe6/bk0anR5Mb86ETsCXUZJqR9hitbAGB0hAcQ2/n88b9f H8ltCNwkCCANhRYor06CYEUcpj0PuLXx//uLqOFA+7asY3DRdmFGPq50GGWo4cc= X-Google-Smtp-Source: AGHT+IEoGfHnBzMFCw1kas9JnSy5+0ILMUWD2fOAFaiwR1CY3kuhA05bT9GSwNNDiMvl8++QtM7cRA== X-Received: by 2002:a05:6808:1512:b0:3e6:b47:6226 with SMTP id 5614622812f47-3e79472024fmr14497720b6e.27.1731388245603; Mon, 11 Nov 2024 21:10:45 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7f41f65bfbdsm9570432a12.75.2024.11.11.21.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2024 21:10:45 -0800 (PST) Date: Mon, 11 Nov 2024 21:05:05 -0800 From: Stephen Hemminger To: Yong Zhang Cc: thomas@monjalon.net, dev@dpdk.org, wang.yong19@zte.com.cn, li.min10@zte.com.cn, ran.ming@zte.com.cn Subject: Re: [v4,2/5] raw/gdtc: add support for queue setup operation Message-ID: <20241111210505.690b0e6b@hermes.local> In-Reply-To: <20241029134609.2499338-3-zhang.yong25@zte.com.cn> References: <20241029134609.2499338-1-zhang.yong25@zte.com.cn> <20241029134609.2499338-3-zhang.yong25@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Tue, 29 Oct 2024 21:45:24 +0800 Yong Zhang wrote: > + /* Init sw_ring */ > + memset(name, 0, sizeof(name)); > + snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "gdma_vq%d_sw_ring", queue_id); > + size = queue->queue_size * sizeof(struct zxdh_gdma_job *); > + queue->sw_ring.job = rte_zmalloc(name, size, 0); This works as is, but: 1. Do not need memset() before snprintf since snprintf will create null terminated string 2. rte_zmalloc() doesn't really care about the name arg 3. You should be using rte_calloc() if it is an array, because that is more common and may help some checkers in future when DPDK can tell compiler that rte_calloc is functional equivalent of calloc(). 4. The name is being used as a memzone name, and not a rawdev name. RTE_RAWDEV_NAME_MAX_LEN = 64 RTE_MEMZONE_NAMESIZE = 32 so you are at some risk of future bug where memzone names becomes too long. > + > + if (queue->sw_ring.job != NULL) > + rte_free(queue->sw_ring.job); > + > + if (queue->ring.ring_mz != NULL) > + rte_memzone_free(queue->ring.ring_mz); Both these function handle NULL as a no-op, so the check for NULL is unnecessary. There is a coccinelle script that finds these.