From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by dpdk.org (Postfix) with ESMTP id 3599A12A8 for ; Tue, 14 Apr 2015 16:54:36 +0200 (CEST) Received: by wiun10 with SMTP id n10so25121730wiu.1 for ; Tue, 14 Apr 2015 07:54:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=BPUeU1eGOOpQoEuMwaJHVZIDLwtMdw9dqUz35qj7aro=; b=aM6r1UwotASpKLDFC0GoIDkYWk17xsAA4JJk2UihvnDLCmFAe8QdilGfjXS7gG5/2R NetcnO+121z7RzXv5I7a5l7WlvtV6AjAy12tJJxDuZSTQmmK53Rbin3fUEYZDLj998jl qmUCFdHFRU1vv+tWbNuDE4N1Hg1bTUPK3vnp+N2whYv7OAs6HcHsFylRGE6XambXs1tb W5nzwgbs/rrr4te4N57PF/inXInD/92/PHXGqeiI6tpYPzfCB0ka6U/gDEUT1AC2WXr+ xIwvUlf07G0Uk4QEJdJFtB2RJ9joCmK1Svze+ujLgYOJlVB7RzO9fdjtE7u5OVnqYof+ KwTA== X-Gm-Message-State: ALoCoQnwYG1mhPymZlYulgxmo6+O94dDmzKp3R51hrQnns+IQ2K5VGdnSvAtSvwpEgWRyM86tAY+ X-Received: by 10.194.59.199 with SMTP id b7mr40553167wjr.26.1429023276042; Tue, 14 Apr 2015 07:54:36 -0700 (PDT) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id xy2sm1918957wjc.14.2015.04.14.07.54.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2015 07:54:35 -0700 (PDT) From: Thomas Monjalon To: Vlad Zolotarov Date: Tue, 14 Apr 2015 16:53:54 +0200 Message-ID: <1672329.GelmR7Xu11@xps13> Organization: 6WIND User-Agent: KMail/4.14.4 (Linux/3.18.4-1-ARCH; KDE/4.14.4; x86_64; ; ) In-Reply-To: <552D247D.9040204@cloudius-systems.com> References: <1429003900-20074-1-git-send-email-thomas.monjalon@6wind.com> <54963304.brPH8sEe9A@xps13> <552D247D.9040204@cloudius-systems.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] ixgbe: fix build with gcc 4.4 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Apr 2015 14:54:36 -0000 2015-04-14 17:30, Vlad Zolotarov: > On 04/14/15 17:17, Thomas Monjalon wrote: > > 2015-04-14 16:38, Vlad Zolotarov: > >> On 04/14/15 16:06, Ananyev, Konstantin wrote: > >>> From: Vlad Zolotarov [mailto:vladz@cloudius-systems.com] > >>>> On 04/14/15 12:31, Thomas Monjalon wrote: > >>>>> - struct rte_eth_dev_info dev_info = { 0 }; > >>>>> + struct rte_eth_dev_info dev_info = { .max_rx_queues = 0 }; > >>>> Hmmm... Unless I miss something this and one above would zero only a > >>>> single field - "max_rx_queues"; and would leave the rest uninitialized. > >>>> The original code intend to zero the whole struct. The alternative to > >>>> the original lines could be usage of memset(). > >>> As I understand, in that case compiler had to set all non-explicitly initialised members to 0. > >>> So I think we are ok here. > >> Yeah, I guess it does zero-initializes the rest > >> (https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html) however I > >> don't understand how the above change fixes the error if it complains > >> about the dev_info.driver_name? > > As only 1 field is required, I chose the one which should not be removed > > from this structure in the future. > > I don't follow - where/why only one field is required? The function u > are patching uses "rx_offload_capa" field. Or u mean this gcc version > requires only one field? If so, could u, please, provide the errata u > are referring, since standard doesn't require any field and {0} is an > absolutely legal (and proper) initializer in this case... Honestly I don't really care what is "legal". The most important is to make it working with most C compilers with minimal overhead. You're right about the variable choice: rx_offload_capa is more appropriate. Are you OK for a v2 replacing max_rx_queues by rx_offload_capa? > >> What I'm trying to say - the proposed fix is completely unclear and > >> confusing. Think of somebody reading this line in a month from today - > >> he wouldn't get a clue why is it there, why to explicitly set > >> max_rx_queues to zero and leave the rest be zeroed automatically... Why > >> to add such artifacts to the code instead of just zeroing the struct > >> with a memset() and putting a good clear comment above it explaining why > >> we use a memset() and not and initializer? > > We can make it longer yes. > > I think you agree we should avoid extra lines if not needed. > > In this case, when reading "= { .field = 0 }", it seems clear our goal > > is to zero the structure (it is to me). > > I thought it is a basic C practice. > > > > You should try "git grep '\.[^ ]\+ *= *0 *}'" to be convinced that we are > > not going to comment each occurence of this coding style. > > But it must be explained in the coding style document. Agree? >