This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28388D: Question about 3 warnings when building DriverLib from source on F28388D

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE

I am working with the ethernet_ipc_ex1_basic example for the TMS320F28388D in CCS.

Previously I was using driverlib.lib, but I removed that library and started building the source files from the driverlib folder directly as part of the project. After doing that, I started seeing a few warnings in original DriverLib source files, and I would like to confirm whether this is expected or whether it indicates a real issue.

The warnings I am seeing are the following:

  1. In ethernet.c, inside Ethernet_retrieveRxPacket(), the variable newPktPtr is reported as assigned but never used.
    Example:
Ethernet_Pkt_Desc *newPktPtr = 0U; ... newPktPtr = (*Ethernet_device_struct.initConfig.pfcbRxPacket)(...);

From the function flow, it seems the value is assigned but never read afterwards. Is this an original legacy TI code path, or is there supposed to be a later use of this variable?

  1. In pmbus.c, variables such as:
const uint32_t fastPlusLow = 20000000U, fastPlusHigh = 25000000U;

are reported as “never used”, even though they appear in an if condition. I would like to know whether this is typically a false positive from the editor/clangd analysis, or whether there is some compilation condition (#ifdef, macro, etc.) that makes this warning appear.

  1. I also see warnings for pointer initialization with 0U, for example:
Ethernet_Pkt_Desc *newPktPtr = 0U;

I understand that NULL would be more typical here. Does TI consider this warning expected and harmless in DriverLib sources, or is there any recommendation to update such code when building DriverLib from source?

My environment:

  • CCS Version: 20.5.0.28__1.11.0 
  • C2000Ware 26.00.00.00
  • F28388D
  • project based on the original TI example
  • warnings started appearing only after switching from the prebuilt .lib to compiling the DriverLib .c sources directly

I would like to confirm:

  • whether these warnings are expected in the original sources
  • whether they can be safely ignored
  • or whether there is an official recommendation for building DriverLib from source without these diagnostics, how to supress this warning

Thank you.

  • Hi,

    I analysed all the three warnings that you mention. 

    1. NewPktPtr "assigned but never used" in ethernet.c
    - False positive: The variable IS used (lines 2942, 2964, 2973), but the compiler cannot trace data flow through the function pointer callback pfcbRxPacket.
    - Safe to ignore.

    2. fastPlusLow and fastPlusHigh unused in pmbus.c
    - Genuine dead code: These constants were likely placeholders for future FastPlus mode support but are not referenced in the current implementation, sort of legacy code, but again, nothing that breaks functionality.
    - Safe to ignore - does not affect functionality.

    3. Pointer initialization with 0U instead of NULL
    - TI coding style: TI uses 0U consistently throughout DriverLib.
    - Safe to ignore


    You can suppress these warnings by adding some flags in your makefile or CCS settings:

    Compiler Flag Syntax

    Add these flags to your compiler options:

    --diag_suppress=179 # variable declared but never referenced
    --diag_suppress=552 # variable set but never used
    --diag_suppress=238   # controlling expression is constant (for ASSERT macros)

    Makefile Implementation

    Option 1: Global suppression for all files
    # Add to CFLAGS
    CFLAGS += --diag_suppress=179 --diag_suppress=552 --diag_suppress=238

    # Example complete CFLAGS
    CFLAGS = -v28 -ml -mt --float_support=fpu32 \
    --diag_suppress=179 --diag_suppress=552  --diag_suppress=238\
    -O2 --opt_for_speed=5

    Option 2: Suppress only for DriverLib files
    # Separate flags for DriverLib sources
    DRIVERLIB_CFLAGS = $(CFLAGS) --diag_suppress=179 --diag_suppress=552 --diag_suppress=238

    # Apply to specific files
    driverlib/%.obj: driverlib/%.c
    $(CC) $(DRIVERLIB_CFLAGS) -c $< -o $@

    Option 3: Per-file suppression
    ethernet.obj: ethernet.c
    $(CC) $(CFLAGS) --diag_suppress=179,552,238 -c $< -o $@

    pmbus.obj: pmbus.c
    $(CC) $(CFLAGS) --diag_suppress=179,552,238 -c $< -o $@

    Regards,
    Shaunak