From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by dpdk.org (Postfix) with ESMTP id 8C182271 for ; Tue, 19 Dec 2017 16:31:33 +0100 (CET) Received: by mail-pf0-f196.google.com with SMTP id d23so11243838pfe.9 for ; Tue, 19 Dec 2017 07:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qzyRf6Z29sV7qDbfqDSeVeI2KjoJYiEirqIFC5wGaMg=; b=tjw7GjfOgSXpta0XTLPES7c6MOhHxy60NCPE8szXYZrbJCIYWPGXOATkdXRLjnnMeD x6t+RLJpWNRhKiEC8OO6lLrVtuBLs6fczL+IzSbvr0JpBKtvpaAUFByPoED5W+3emvk3 MdVbGnr6qKWXQOc2cfKNwjj6M+8NGIf3re1KMx2JvSQxEliuSEajVV7u2maeoxwExlTH 17pVnbhjYk0XaFosWJDrrntBDsYZY8BOL1kQKy7fQPSiY2rI66PsFV7Z60aRp5cOJFgx HQ3DZ5o+7e0SIfLqZEs6Pp2Bk95uweY8Po6bzlrjCADIJdpQL/a/GmRkNd4iFbUKgkd7 mQKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qzyRf6Z29sV7qDbfqDSeVeI2KjoJYiEirqIFC5wGaMg=; b=hi3cdUqYYANQRF6FWUXgWnY1ZRLqQDxLTIOjDMK+bU7Aw8VrlnImCsj/aJZ2rpA//k k/exASFilAPw4rpzcL11xhqfI4DRORaLv4+QIgAhB+9jpYP0E+cYJMAF6vqZ45FXe+HK Yn8d3NbI4HHAsAZdPMTje3nvrUHLV5BXox6eHO6hdUnl3ceAdKJcFb9EGHzcOka4YDZM EAeZPq7fj+sYxT+47lor1Hxv1vRBdR0Wuf8ImDbD+Kp/67N1d8a6/OxN7Xf0ONT9nZo8 1cDVmv6qr+bpLKK+fsQ6237yUEfvyWY+aqeFFH01CNmQdhQycY1qm9AfosfCMTdwy5Io JA9A== X-Gm-Message-State: AKGB3mI013Q1g9o9+y7oXKevMeyC/ZFZ1wprhvzmz/+ow/VPpCfC/qeV 2c301UuEDnmJt+LDKMs0tMCzxbqSwjE= X-Google-Smtp-Source: ACJfBouNDfE7bzcHRQFHYsentM4xke1msigYR5fuGddb1eAeUSG17rnyHFKTz+zSHtko/d43Iu5YXA== X-Received: by 10.101.81.68 with SMTP id g4mr3351824pgq.166.1513697492383; Tue, 19 Dec 2017 07:31:32 -0800 (PST) Received: from xeon-e3 (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id g5sm24285374pgq.71.2017.12.19.07.31.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Dec 2017 07:31:32 -0800 (PST) Date: Tue, 19 Dec 2017 07:31:30 -0800 From: Stephen Hemminger To: Adrien Mazarguil Cc: Bruce Richardson , Ferruh Yigit , dev@dpdk.org Message-ID: <20171219073130.3b9662b0@xeon-e3> In-Reply-To: <20171219101538.GC5377@6wind.com> References: <20171124172132.GW4062@6wind.com> <20171218162443.12971-1-adrien.mazarguil@6wind.com> <20171218162443.12971-3-adrien.mazarguil@6wind.com> <20171218103412.342adcbc@xeon-e3> <20171218202341.GF4062@6wind.com> <20171219095326.GA7384@bricha3-MOBL3.ger.corp.intel.com> <20171219101538.GC5377@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v1 2/3] net/hyperv: implement core functionality X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Dec 2017 15:31:33 -0000 On Tue, 19 Dec 2017 11:15:38 +0100 Adrien Mazarguil wrote: > On Tue, Dec 19, 2017 at 09:53:27AM +0000, Bruce Richardson wrote: > > On Mon, Dec 18, 2017 at 09:23:41PM +0100, Adrien Mazarguil wrote: > > > On Mon, Dec 18, 2017 at 10:34:12AM -0800, Stephen Hemminger wrote: > > > > On Mon, 18 Dec 2017 17:46:23 +0100 > > > > Adrien Mazarguil wrote: > > > > > > > > > > > +static int > > > > > +hyperv_iface_is_netvsc(const struct if_nameindex *iface) > > > > > +{ > > > > > + static const char temp[] = "/sys/class/net/%s/device/class_id"; > > > > > + char path[snprintf(NULL, 0, temp, iface->if_name) + 1]; > > > > > > > > Doing this snprintf is gross. Either use PATH_MAX or asprintf > > > > > > I don't think allocating more stack space than necessary or on the heap with > > > a possible allocation failure to deal with is any better, sorry. > > > > > > Prove this snprintf() call can fail and you'll have a point. > > > > > While I get your point, I'd tend to go with Stephen's view on this that > > it's looking a bit "gross". What's the problem with allocating a bit > > more stack space for it? > > Well, apart from making a stand, none really. Too "unusual" perhaps, but I > don't think "gross" is a valid argument to reject a perfectly valid piece of > code that doesn't rely on obscure knowledge nor weird side effects. > > I'll update this in v2 to make it look more acceptable in any case. > In this particular case, you can easily show that the maximum length of the string would be less than the format plus maximum length of interface name. Why not: char path[sizeof(temp) + IFNAMSIZ]; which keeps the flexibility but also can be evaluated at compile time. Upleveling. You need to understand that open source software is a collabrative effort. And like doing improvisational theatre, the best answer to any feedback is yes unless there is a technical reason otherwise.