From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor <natechancellor@gmail.com>, Nick Desaulniers <ndesaulniers@google.com>, Tyrel Datwyler <tyreld@linux.ibm.com>, Joel Savitz <jsavitz@redhat.com>, Michael Ellerman <mpe@ellerman.id.au>, Sasha Levin <sashal@kernel.org>, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.2 17/70] PCI: rpaphp: Avoid a sometimes-uninitialized warning Date: Tue, 24 Sep 2019 12:44:56 -0400 [thread overview] Message-ID: <20190924164549.27058-17-sashal@kernel.org> (raw) In-Reply-To: <20190924164549.27058-1-sashal@kernel.org> From: Nathan Chancellor <natechancellor@gmail.com> [ Upstream commit 0df3e42167caaf9f8c7b64de3da40a459979afe8 ] When building with -Wsometimes-uninitialized, clang warns: drivers/pci/hotplug/rpaphp_core.c:243:14: warning: variable 'fndit' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized] for (j = 0; j < entries; j++) { ^~~~~~~~~~~ drivers/pci/hotplug/rpaphp_core.c:256:6: note: uninitialized use occurs here if (fndit) ^~~~~ drivers/pci/hotplug/rpaphp_core.c:243:14: note: remove the condition if it is always true for (j = 0; j < entries; j++) { ^~~~~~~~~~~ drivers/pci/hotplug/rpaphp_core.c:233:14: note: initialize the variable 'fndit' to silence this warning int j, fndit; ^ = 0 fndit is only used to gate a sprintf call, which can be moved into the loop to simplify the code and eliminate the local variable, which will fix this warning. Fixes: 2fcf3ae508c2 ("hotplug/drc-info: Add code to search ibm,drc-info property") Suggested-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Acked-by: Tyrel Datwyler <tyreld@linux.ibm.com> Acked-by: Joel Savitz <jsavitz@redhat.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://github.com/ClangBuiltLinux/linux/issues/504 Link: https://lore.kernel.org/r/20190603221157.58502-1-natechancellor@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/pci/hotplug/rpaphp_core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index bcd5d357ca238..c3899ee1db995 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -230,7 +230,7 @@ static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, struct of_drc_info drc; const __be32 *value; char cell_drc_name[MAX_DRC_NAME_LEN]; - int j, fndit; + int j; info = of_find_property(dn->parent, "ibm,drc-info", NULL); if (info == NULL) @@ -245,17 +245,13 @@ static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, /* Should now know end of current entry */ - if (my_index > drc.last_drc_index) - continue; - - fndit = 1; - break; + /* Found it */ + if (my_index <= drc.last_drc_index) { + sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, + my_index); + break; + } } - /* Found it */ - - if (fndit) - sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, - my_index); if (((drc_name == NULL) || (drc_name && !strcmp(drc_name, cell_drc_name))) && -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin <sashal@kernel.org>, Tyrel Datwyler <tyreld@linux.ibm.com>, Nick Desaulniers <ndesaulniers@google.com>, clang-built-linux@googlegroups.com, linux-pci@vger.kernel.org, Nathan Chancellor <natechancellor@gmail.com>, linuxppc-dev@lists.ozlabs.org, Joel Savitz <jsavitz@redhat.com> Subject: [PATCH AUTOSEL 5.2 17/70] PCI: rpaphp: Avoid a sometimes-uninitialized warning Date: Tue, 24 Sep 2019 12:44:56 -0400 [thread overview] Message-ID: <20190924164549.27058-17-sashal@kernel.org> (raw) In-Reply-To: <20190924164549.27058-1-sashal@kernel.org> From: Nathan Chancellor <natechancellor@gmail.com> [ Upstream commit 0df3e42167caaf9f8c7b64de3da40a459979afe8 ] When building with -Wsometimes-uninitialized, clang warns: drivers/pci/hotplug/rpaphp_core.c:243:14: warning: variable 'fndit' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized] for (j = 0; j < entries; j++) { ^~~~~~~~~~~ drivers/pci/hotplug/rpaphp_core.c:256:6: note: uninitialized use occurs here if (fndit) ^~~~~ drivers/pci/hotplug/rpaphp_core.c:243:14: note: remove the condition if it is always true for (j = 0; j < entries; j++) { ^~~~~~~~~~~ drivers/pci/hotplug/rpaphp_core.c:233:14: note: initialize the variable 'fndit' to silence this warning int j, fndit; ^ = 0 fndit is only used to gate a sprintf call, which can be moved into the loop to simplify the code and eliminate the local variable, which will fix this warning. Fixes: 2fcf3ae508c2 ("hotplug/drc-info: Add code to search ibm,drc-info property") Suggested-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Acked-by: Tyrel Datwyler <tyreld@linux.ibm.com> Acked-by: Joel Savitz <jsavitz@redhat.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://github.com/ClangBuiltLinux/linux/issues/504 Link: https://lore.kernel.org/r/20190603221157.58502-1-natechancellor@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/pci/hotplug/rpaphp_core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index bcd5d357ca238..c3899ee1db995 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -230,7 +230,7 @@ static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, struct of_drc_info drc; const __be32 *value; char cell_drc_name[MAX_DRC_NAME_LEN]; - int j, fndit; + int j; info = of_find_property(dn->parent, "ibm,drc-info", NULL); if (info == NULL) @@ -245,17 +245,13 @@ static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, /* Should now know end of current entry */ - if (my_index > drc.last_drc_index) - continue; - - fndit = 1; - break; + /* Found it */ + if (my_index <= drc.last_drc_index) { + sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, + my_index); + break; + } } - /* Found it */ - - if (fndit) - sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, - my_index); if (((drc_name == NULL) || (drc_name && !strcmp(drc_name, cell_drc_name))) && -- 2.20.1
next prev parent reply other threads:[~2019-09-24 16:46 UTC|newest] Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-24 16:44 [PATCH AUTOSEL 5.2 01/70] drm/vkms: Fix crc worker races Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 02/70] drm/bridge: tc358767: Increase AUX transfer length limit Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 03/70] drm/bridge: adv7511: Attach to DSI host at probe time Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 04/70] drm/kms: Catch mode_object lifetime errors Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 05/70] drm/vkms: Avoid assigning 0 for possible_crtc Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 06/70] drm/panel: simple: fix AUO g185han01 horizontal blanking Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 07/70] drm/amd/display: add monitor patch to add T7 delay Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 08/70] video: ssd1307fb: Start page range at page_offset Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 09/70] drm/tinydrm/Kconfig: drivers: Select BACKLIGHT_CLASS_DEVICE Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 10/70] drm/stm: attach gem fence to atomic state Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 11/70] drm/panel: check failure cases in the probe func Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 12/70] drm/rockchip: Check for fast link training before enabling psr Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 13/70] drm/amdgpu: Fix hard hang for S/G display BOs Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 14/70] drm/radeon: Fix EEH during kexec Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 15/70] gpu: drm: radeon: Fix a possible null-pointer dereference in radeon_connector_set_property() Sasha Levin 2019-09-24 16:44 ` Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 16/70] clk: imx8mq: Mark AHB clock as critical Sasha Levin 2019-09-24 16:44 ` Sasha Levin [this message] 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 17/70] PCI: rpaphp: Avoid a sometimes-uninitialized warning Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 18/70] pinctrl: stmfx: update pinconf settings Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 19/70] ipmi_si: Only schedule continuously in the thread in maintenance mode Sasha Levin 2019-09-24 16:44 ` [PATCH AUTOSEL 5.2 20/70] clk: qoriq: Fix -Wunused-const-variable Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 21/70] clk: sunxi-ng: v3s: add missing clock slices for MMC2 module clocks Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 22/70] drm/amd/display: fix issue where 252-255 values are clipped Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 23/70] drm/amd/display: Fix frames_to_insert math Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 24/70] drm/amd/display: reprogram VM config when system resume Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 25/70] powerpc/powernv/ioda2: Allocate TCE table levels on demand for default DMA window Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 26/70] drm/amd/powerplay/smu7: enforce minimal VBITimeout (v2) Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 27/70] clk: actions: Don't reference clk_init_data after registration Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 28/70] clk: sirf: " Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 29/70] clk: meson: axg-audio: " Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 30/70] clk: sprd: " Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 31/70] clk: zx296718: " Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 32/70] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 33/70] powerpc/rtas: use device model APIs and serialization during LPM Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 34/70] powerpc/futex: Fix warning: 'oldval' may be used uninitialized in this function Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 35/70] powerpc/64s/radix: Remove redundant pfn_pte bitop, add VM_BUG_ON Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 36/70] powerpc/64s/radix: Fix memory hotplug section page table creation Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 37/70] powerpc/pseries/mobility: use cond_resched when updating device tree Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 38/70] powerpc/perf: fix imc allocation failure handling Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 39/70] pinctrl: tegra: Fix write barrier placement in pmx_writel Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 40/70] powerpc/eeh: Clear stale EEH_DEV_NO_HANDLER flag Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 41/70] vfio_pci: Restore original state on release Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 42/70] drm/nouveau/kms/tu102-: disable input lut when input is already FP16 Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 43/70] drm/nouveau/volt: Fix for some cards having 0 maximum voltage Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 44/70] pinctrl: amd: disable spurious-firing GPIO IRQs Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 45/70] clk: renesas: mstp: Set GENPD_FLAG_ALWAYS_ON for clock domain Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 46/70] clk: renesas: cpg-mssr: " Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 47/70] drm/amd/display: support spdif Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 48/70] selftests/powerpc: Retry on host facility unavailable Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 49/70] drm/amdgpu/si: fix ASIC tests Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 50/70] powerpc/64s/exception: machine check use correct cfar for late handler Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 51/70] pstore: fs superblock limits Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 52/70] powerpc/eeh: Clean up EEH PEs after recovery finishes Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 53/70] powerpc/imc: Dont create debugfs files for cpu-less nodes Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 54/70] clk: qcom: gcc-sdm845: Use floor ops for sdcc clks Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 55/70] powerpc/pseries: correctly track irq state in default idle Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 56/70] pinctrl: meson-gxbb: Fix wrong pinning definition for uart_c Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 57/70] mailbox: mediatek: cmdq: clear the event in cmdq initial flow Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 58/70] arm64: fix unreachable code issue with cmpxchg Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 59/70] clk: at91: select parent if main oscillator or bypass is enabled Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 60/70] clk: imx: pll14xx: avoid glitch when set rate Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 61/70] clk: imx: clk-pll14xx: unbypass PLL by default Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 62/70] clk: Make clk_bulk_get_all() return a valid "id" Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 63/70] powerpc: dump kernel log before carrying out fadump or kdump Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 64/70] mbox: qcom: add APCS child device for QCS404 Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 65/70] clk: sprd: add missing kfree Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 66/70] scsi: core: Reduce memory required for SCSI logging Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 67/70] dma-buf/sw_sync: Synchronize signal vs syncpt free Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 68/70] drm: fix module name in edid_firmware log message Sasha Levin 2019-09-24 16:45 ` Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 69/70] f2fs: fix to drop meta/node pages during umount Sasha Levin 2019-09-24 16:45 ` [f2fs-dev] " Sasha Levin 2019-09-24 16:45 ` [PATCH AUTOSEL 5.2 70/70] ext4: fix potential use after free after remounting with noblock_validity Sasha Levin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190924164549.27058-17-sashal@kernel.org \ --to=sashal@kernel.org \ --cc=clang-built-linux@googlegroups.com \ --cc=jsavitz@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pci@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --cc=natechancellor@gmail.com \ --cc=ndesaulniers@google.com \ --cc=stable@vger.kernel.org \ --cc=tyreld@linux.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.