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 CD6C545C53; Sat, 2 Nov 2024 06:43:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A7724026C; Sat, 2 Nov 2024 06:43:14 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 6D8864026B for ; Sat, 2 Nov 2024 06:43:13 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-71e625b00bcso2269236b3a.3 for ; Fri, 01 Nov 2024 22:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1730526192; x=1731130992; 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=CWCkdspV4dhN99sihMtLpPwhTZQJ7zNuQsnHXTN+Gqc=; b=wHC3GS/NMx9oS0usrAo1jIxsPaloDVR3GlPc2qOZyfU16n2rENiky5yEnbwCv/g0Ls jJjxz2vTahNf1Yr8Aer+xvqa4GlRJbPE3F+qWR6nmzaPHrm3eU+ddO3vVGJH2XYCzLjR M1x8jYVZP6aV+IikvRM4hTjA98nDXrbrv/Uo7A4IOtMgGLfWZup/GHFjQOyve9MfiVHS HXZIpiSe1ml2an4me7qJwZCe7hGo4vLcuFv9nqqS2OZfmQS0OtnG3kj3T14+wU5Jb1r6 T3hh3YnwE3GjMAz0QKgqUZxlucHiURZRLpEYCpM3nvNhXflbshvT4vIEAib2yRsvMWw8 w2Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730526192; x=1731130992; 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=CWCkdspV4dhN99sihMtLpPwhTZQJ7zNuQsnHXTN+Gqc=; b=U/VJCpgb3QIHxEFv6tdlL2MKPQbOFP40ROo4jTgcLA/BXqgmYoMJjqlGECZc/iGBGR FJwicJUbN5psuSgbySOUZCFSaniQh2lhRdD8PQ5rKGShVW99DTCHBsXhLEE4NkWQB5Dw KparUnElpVM+/me19v7HbfheB33MYiXNdkUTMDpmXoQUFIlf4JIwuRBo181Bc8Hgggs6 cqrbFzgSy1ot3ABrKw1NQO+nM38tzl7w6KFz537oVU7EDg/j3plGtmpSFyVmmQiixEt/ afoy9U+uDMAD+zFx+4wDHOKxEbWFZx5FHduOyQxXvpkw3jtqUV+vm5VD3a9mcLbmMdZg oM2A== X-Gm-Message-State: AOJu0YxJjFOZ6Idv4fTke/Yz38xvS3urQVu/mtafvLuDWcmD4R1XJebw 1+n0hXgqhaaYZ4REgpb5gttoHtH7nkaeZQ8d09nZXMhtNffGFVyw7XFW4WfEd91HK/s3yGj0AAJ A X-Google-Smtp-Source: AGHT+IHygD7v/z7b9ErimenRCSYzE3HkaqGN5riSrtxKByZGM/qSZ6i7vUIoAWGO8GxSZCGaiI32dw== X-Received: by 2002:a05:6a00:10cf:b0:71e:6a99:472f with SMTP id d2e1a72fcca58-720b9de116emr12669744b3a.24.1730526192480; Fri, 01 Nov 2024 22:43:12 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bbfc35b2sm3581498b3a.0.2024.11.01.22.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 22:43:12 -0700 (PDT) Date: Fri, 1 Nov 2024 22:43:10 -0700 From: Stephen Hemminger To: liwencheng Cc: dev@dpdk.org Subject: Re: [PATCH v1 1/2] net/macb: add new driver Message-ID: <20241101224310.2564e1b2@hermes.local> In-Reply-To: <1730455640-1084345-1-git-send-email-liwencheng@phytium.com.cn> References: <1730455640-1084345-1-git-send-email-liwencheng@phytium.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 Fri, 1 Nov 2024 10:07:19 +0000 liwencheng wrote: > +int macb_uio_init(const char *name, struct macb_iomem **iomem) > +{ > + struct macb_iomem *new; > + int ret; > + > + new = malloc(sizeof(struct macb_iomem)); > + if (!new) { > + MACB_LOG(ERR, "No memory for IOMEM obj."); > + return -ENOMEM; > + } > + memset(new, 0, sizeof(struct macb_iomem)); > + > + new->name = malloc(strlen(name) + 1); > + if (!new->name) { > + MACB_LOG(ERR, "No memory for IOMEM-name obj."); > + ret = -ENOMEM; > + goto out_free; > + } > + > + memcpy(new->name, name, strlen(name)); > + new->name[strlen(name)] = '\0'; This looks like you just reinvented strdup() function and did with calling strlen() multiple times.