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 8B6E0A04FF; Tue, 24 May 2022 11:03:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B1CD4067B; Tue, 24 May 2022 11:03:46 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 72F7E400D6 for ; Tue, 24 May 2022 11:03:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653383024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sDdKgycEF3iP3hMb15ihJl/8kz8e0ppaMJ1g5/wVGXQ=; b=PAd8urmmGPymH5BjKhcC3wcaZSj+bhJyCgPHv2huAaa9jIB0aTyi9+5Bc/EHcsQ85Yz+7r WY9e/Txti33XV3RrjIb3ziSkV6LlDkVrCMrHTTOjm/MhENs/J9qrW3OIxGhHd1xvaTBynO NZ8JsNN348PmKc7Fl8/JGpG67PpKHW0= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-uLrsk_rjMNyWu0r3qnNxWQ-1; Tue, 24 May 2022 05:03:43 -0400 X-MC-Unique: uLrsk_rjMNyWu0r3qnNxWQ-1 Received: by mail-lf1-f71.google.com with SMTP id j4-20020a056512398400b0047866b0b823so3438004lfu.19 for ; Tue, 24 May 2022 02:03:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=sDdKgycEF3iP3hMb15ihJl/8kz8e0ppaMJ1g5/wVGXQ=; b=tzglRszrQbJ7QyDAcpvjwhdS0LiRNIO/0dAYG9I7BxYWugUibbUbOOTsl3VHpI3ljO DrME7BwQB6KWdGmc6yKnfGzWLWOSjh4XqFkxLLOdwoYJKxdMI9qzrVjMEIRQkPcKuXd5 G6Y3kMJ9mgxzfJbqbLQTG+RHjmOiTkqIXqve6b8w4db3rWn6mfGW/fwsTRLCzeW1w7iC YmdPGdDB2f692pkC2QrhMsJBLstUb+h48oyw3kwjX+GHQ6aPBSJwSlW6v7Iw8TfS0pql awfM1/rxU3HPWG6CQ+FiDbbN645ZyjHAHonc4KB/5wELdloO5zKF8I+ibtc1fBrDb91B wMOw== X-Gm-Message-State: AOAM533Tii4m41KvLIdXYTcQVXKeXTU622ZfBmsewiWugG1ZSJzt23BT hRzsyedS/ZfkKIwazx8iQqrWz13JrIan/EIgOSc7wq35psJnClfXeTfGVQdmYrAkBE0lp6y3YND 9Met0tHDNCboy8PPwKHM= X-Received: by 2002:ac2:4c22:0:b0:478:7c35:a023 with SMTP id u2-20020ac24c22000000b004787c35a023mr4607162lfq.484.1653383022185; Tue, 24 May 2022 02:03:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJBoiggng6oUORg7PozBwUDU3+NcBf/ooFyq162nD9X6ZG2Pf4i7U81D7jD4HBUL92YS/si6X+rumwAKkAYn4= X-Received: by 2002:ac2:4c22:0:b0:478:7c35:a023 with SMTP id u2-20020ac24c22000000b004787c35a023mr4607153lfq.484.1653383021999; Tue, 24 May 2022 02:03:41 -0700 (PDT) MIME-Version: 1.0 References: <20220511021442.811950-1-robinx.zhang@intel.com> <20220524062442.194809-1-robinx.zhang@intel.com> <20220524062442.194809-6-robinx.zhang@intel.com> In-Reply-To: <20220524062442.194809-6-robinx.zhang@intel.com> From: David Marchand Date: Tue, 24 May 2022 11:03:30 +0200 Message-ID: Subject: Re: [PATCH v7 5/5] ethdev: format module EEPROM for SFF-8636 To: Robin Zhang Cc: dev , Thomas Monjalon , Andrew Rybchenko , kevinx.liu@intel.com Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Hello, I see a lot of switch / case where tables could do the job. In any case, I'll focus only on one part of the code, that triggers a build warning witch clang 14 (+ ASan): On Tue, May 24, 2022 at 8:31 AM Robin Zhang wrote: > + /* Channel Specific Data */ > + for (i =3D 0; i < MAX_CHANNEL_NUM; i++) { > + uint8_t rx_power_offset, tx_bias_offset; > + uint8_t tx_power_offset; > + > + switch (i) { > + case 0: > + rx_power_offset =3D SFF_8636_RX_PWR_1_OFFSET; > + tx_power_offset =3D SFF_8636_TX_PWR_1_OFFSET; > + tx_bias_offset =3D SFF_8636_TX_BIAS_1_OFFSET; > + break; > + case 1: > + rx_power_offset =3D SFF_8636_RX_PWR_2_OFFSET; > + tx_power_offset =3D SFF_8636_TX_PWR_2_OFFSET; > + tx_bias_offset =3D SFF_8636_TX_BIAS_2_OFFSET; > + break; > + case 2: > + rx_power_offset =3D SFF_8636_RX_PWR_3_OFFSET; > + tx_power_offset =3D SFF_8636_TX_PWR_3_OFFSET; > + tx_bias_offset =3D SFF_8636_TX_BIAS_3_OFFSET; > + break; > + case 3: > + rx_power_offset =3D SFF_8636_RX_PWR_4_OFFSET; > + tx_power_offset =3D SFF_8636_TX_PWR_4_OFFSET; > + tx_bias_offset =3D SFF_8636_TX_BIAS_4_OFFSET; > + break; > + } > + sd->scd[i].bias_cur =3D OFFSET_TO_U16(tx_bias_offset); > + sd->scd[i].rx_power =3D OFFSET_TO_U16(rx_power_offset); > + sd->scd[i].tx_power =3D OFFSET_TO_U16(tx_power_offset); > + } [15/442] Compiling C object lib/librte_ethdev.a.p/ethdev_sff_8636.c.o In file included from ../lib/ethdev/sff_8636.c:13: ../lib/ethdev/sff_common.h: In function =E2=80=98sff_8636_show_all=E2=80=99= : ../lib/ethdev/sff_common.h:101:22: warning: =E2=80=98tx_power_offset=E2=80= =99 may be used uninitialized [-Wmaybe-uninitialized] 101 | (data[offset] << 8 | data[(offset) + 1]) | ^ ../lib/ethdev/sff_8636.c:621:25: note: =E2=80=98tx_power_offset=E2=80=99 wa= s declared here 621 | uint8_t tx_power_offset; | ^~~~~~~~~~~~~~~ ../lib/ethdev/sff_common.h:101:22: warning: =E2=80=98tx_bias_offset=E2=80= =99 may be used uninitialized [-Wmaybe-uninitialized] 101 | (data[offset] << 8 | data[(offset) + 1]) | ^ ../lib/ethdev/sff_8636.c:620:42: note: =E2=80=98tx_bias_offset=E2=80=99 was= declared here 620 | uint8_t rx_power_offset, tx_bias_offset; | ^~~~~~~~~~~~~~ ../lib/ethdev/sff_common.h:101:22: warning: =E2=80=98rx_power_offset=E2=80= =99 may be used uninitialized [-Wmaybe-uninitialized] 101 | (data[offset] << 8 | data[(offset) + 1]) | ^ ../lib/ethdev/sff_8636.c:620:25: note: =E2=80=98rx_power_offset=E2=80=99 wa= s declared here 620 | uint8_t rx_power_offset, tx_bias_offset; | ^~~~~~~~~~~~~~~ [268/268] Linking target app/test/dpdk-test This is a false positive. This can be avoided using some tables: + const uint8_t rx_power_offset[MAX_CHANNEL_NUM] =3D { + SFF_8636_RX_PWR_1_OFFSET, + SFF_8636_RX_PWR_2_OFFSET, + SFF_8636_RX_PWR_3_OFFSET, + SFF_8636_RX_PWR_4_OFFSET, + }; + const uint8_t tx_power_offset[MAX_CHANNEL_NUM] =3D { + SFF_8636_TX_PWR_1_OFFSET, + SFF_8636_TX_PWR_2_OFFSET, + SFF_8636_TX_PWR_3_OFFSET, + SFF_8636_TX_PWR_4_OFFSET, + }; + const uint8_t tx_bias_offset[MAX_CHANNEL_NUM] =3D { + SFF_8636_TX_BIAS_1_OFFSET, + SFF_8636_TX_BIAS_2_OFFSET, + SFF_8636_TX_BIAS_3_OFFSET, + SFF_8636_TX_BIAS_4_OFFSET, + }; + sd->scd[i].bias_cur =3D OFFSET_TO_U16(tx_bias_offset[i]); + sd->scd[i].rx_power =3D OFFSET_TO_U16(rx_power_offset[i]); + sd->scd[i].tx_power =3D OFFSET_TO_U16(tx_power_offset[i]); --=20 David Marchand