Skip to content

BUG: VBI_DEBUG unconditionally defined — debug code always compiled into production builds #2167

@Varadraj75

Description

@Varadraj75

Summary

#define VBI_DEBUG is hardcoded unconditionally in
src/lib_ccx/ccx_decoders_vbi.h line 5, meaning debug-only struct
fields and code are always compiled into every production build.

Affected Code

// ccx_decoders_vbi.h:4
#define VBI_DEBUG   // ← always defined, should be a build option

// Results in these always being compiled in:
struct ccx_decoder_vbi_cfg {
#ifdef VBI_DEBUG
    char *debug_file_name;   // ← always present in every build
#endif
};

struct ccx_decoder_vbi_ctx {
#ifdef VBI_DEBUG
    FILE *vbi_debug_dump;    // ← always present in every build
#endif
};

Comparison With Other Debug Flags

Other debug flags in the codebase are correctly left undefined unless
explicitly set at compile time:

// ccx_common_constants.h:205
#ifdef WTV_DEBUG   // ← never unconditionally defined, opt-in only

VBI_DEBUG is the only debug flag that is unconditionally always-on.

Impact

  • Extra struct fields (debug_file_name, vbi_debug_dump) are present
    in every production build, wasting memory
  • Debug I/O paths are always compiled in, increasing binary size
  • Inconsistent with how all other debug flags work in the codebase

Suggested Fix

Remove #define VBI_DEBUG from the header. Add it as a CMake option
so developers can opt in:

# CMakeLists.txt
option(VBI_DEBUG "Enable VBI debug output" OFF)
if(VBI_DEBUG)
    add_compile_definitions(VBI_DEBUG)
endif()

This matches how other optional debug flags work in the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions