arch/arm64/kernel/proton-pack.c:302:5: warning: Redundant assignment of 'cb' to itself. [selfAssignment]

From: kernel test robot
Date: Sat May 07 2022 - 06:02:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4b97bac0756a81cda5afd45417a99b5bccdcff67
commit: ea8f8c99a28199f6e067581b8626d192b07750f2 arm64: spectre-v2: Favour CPU-specific mitigation at EL2
date: 1 year, 7 months ago
compiler: aarch64-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout ea8f8c99a28199f6e067581b8626d192b07750f2
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


cppcheck warnings: (new ones prefixed by >>)
>> arch/arm64/kernel/proton-pack.c:302:5: warning: Redundant assignment of 'cb' to itself. [selfAssignment]
cb = spectre_v2_get_sw_mitigation_cb() ?: cb;
^

vim +/cb +302 arch/arm64/kernel/proton-pack.c

272
273 static enum mitigation_state spectre_v2_enable_fw_mitigation(void)
274 {
275 bp_hardening_cb_t cb;
276 enum mitigation_state state;
277
278 state = spectre_v2_get_cpu_fw_mitigation_state();
279 if (state != SPECTRE_MITIGATED)
280 return state;
281
282 if (spectre_v2_mitigations_off())
283 return SPECTRE_VULNERABLE;
284
285 switch (arm_smccc_1_1_get_conduit()) {
286 case SMCCC_CONDUIT_HVC:
287 cb = call_hvc_arch_workaround_1;
288 break;
289
290 case SMCCC_CONDUIT_SMC:
291 cb = call_smc_arch_workaround_1;
292 break;
293
294 default:
295 return SPECTRE_VULNERABLE;
296 }
297
298 /*
299 * Prefer a CPU-specific workaround if it exists. Note that we
300 * still rely on firmware for the mitigation at EL2.
301 */
> 302 cb = spectre_v2_get_sw_mitigation_cb() ?: cb;
303 install_bp_hardening_cb(cb);
304 return SPECTRE_MITIGATED;
305 }
306

--
0-DAY CI Kernel Test Service
https://01.org/lkp