Project

General

Profile

Actions

Bug #6190

closed

warning: 'tmp_first_tfi' may be used uninitialized [-Wmaybe-uninitialized]

Added by fixeria 7 months ago. Updated 7 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
-
Start date:
09/24/2023
Due date:
% Done:

0%

Spec Reference:

Description

Seen when building recent osmo-pcu with gcc v13.2.1:

In file included from ../../../src/osmo-pcu/src/gprs_debug.h:21,
                 from ../../../src/osmo-pcu/src/tbf.h:26,
                 from ../../../src/osmo-pcu/src/pdch.h:31,
                 from ../../../src/osmo-pcu/src/bts.h:20,
                 from ../../../src/osmo-pcu/src/bts.cpp:21:
../../../src/osmo-pcu/src/bts.cpp: In function 'int bts_tfi_find_free(const gprs_rlcmac_bts*, gprs_rlcmac_tbf_direction, uint8_t*, int8_t)':
/opt/osmocom/include/osmocom/core/logging.h:107:42: warning: 'tmp_first_tfi' may be used uninitialized [-Wmaybe-uninitialized]
  107 |                                 logp_stub(__FILE__, __LINE__, cont, fmt, ##args); \
      |                                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/osmocom/include/osmocom/core/logging.h:85:9: note: in expansion of macro 'LOGPSRCC'
   85 |         LOGPSRCC(ss, level, caller_file, caller_line, 0, fmt, ##args)
      |         ^~~~~~~~
/opt/osmocom/include/osmocom/core/logging.h:50:9: note: in expansion of macro 'LOGPSRC'
   50 |         LOGPSRC(ss, level, NULL, 0, fmt, ## args)
      |         ^~~~~~~
../../../src/osmo-pcu/src/bts.cpp:663:9: note: in expansion of macro 'LOGP'
  663 |         LOGP(DRLCMAC, LOGL_DEBUG, "Found first unallocated TRX=%d TFI=%d\n",
      |         ^~~~
../../../src/osmo-pcu/src/bts.cpp:645:25: note: 'tmp_first_tfi' was declared here
  645 |                 uint8_t tmp_first_tfi;
      |                         ^~~~~~~~~~~~~
Actions #1

Updated by pespin 7 months ago

  • Assignee changed from pespin to fixeria

I cannot reproduce it using the same gcc version (Arch).

Furthermore, my analysis of trx_count_free_tfi concludes that tmp_first_tfi is always set, so it would be a false positive.

Please fixeria feel free to take care of this yourself by submitting a patch since you are the one getting the error if it hurts you. It's probably a matter of nitializing the variable to make gcc happy.

Actions #2

Updated by fixeria 7 months ago

BTW, I am seeing exactly the same error in Jenkins build logs:

https://jenkins.osmocom.org/jenkins/job/gerrit-binpkgs/2069/consoleFull [almalinux:8]

  CC       pcuif_sock.lo
In file included from ./coding_scheme.h:18,
                 from ./pdch.h:26,
                 from ./bts.h:20,
                 from bts.cpp:21:
/usr/include/libosmocore/osmocom/core/utils.h: In function 'int bts_tfi_find_free(const gprs_rlcmac_bts*, gprs_rlcmac_tbf_direction, uint8_t*, int8_t)':
/usr/include/libosmocore/osmocom/core/utils.h:115:2: warning: 'tmp_first_tfi' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (OSMO_UNLIKELY(!(exp))) { \
  ^~
bts.cpp:645:11: note: 'tmp_first_tfi' was declared here
   uint8_t tmp_first_tfi;
           ^~~~~~~~~~~~~
Actions #3

Updated by fixeria 7 months ago

  • Status changed from New to Feedback

The workaround initializing tmp_first_tfi to 0xff (invalid value) is here:

https://gerrit.osmocom.org/c/osmo-pcu/+/34533 bts: bts_tfi_find_free(): fix -Wmaybe-uninitialized (false positive)

Actions #4

Updated by fixeria 7 months ago

  • Status changed from Feedback to Resolved
Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)