Skip to content

[BUG] networking.c: DEBUG_OUT uses integer toggle instead of CMake opt-in; error messages use printf() instead of fprintf(stderr) #2174

@Varadraj75

Description

@Varadraj75

Summary

Two related issues in src/lib_ccx/networking.c:

Bug 1 — DEBUG_OUT uses #define 0/1 instead of CMake opt-in

// networking.c:11
#define DEBUG_OUT 0  // ← always compiled in, just silenced

This is the same pattern recently fixed for VBI_DEBUG in #2168. Debug
code is always compiled into production builds. The correct approach is
a CMake opt-in option (-DNETWORKING_DEBUG=ON) consistent with how other
debug flags work in the codebase.

Bug 2 — Error messages use printf() instead of fprintf(stderr)

Three error conditions silently write to stdout instead of stderr:

// Line 154 — fatal send failure
printf("Can't send BIN header\n");

// Line 181 — fatal send failure  
printf("Can't send BIN data\n");

// Line 241 — fatal send failure + exit
printf("Unable to send data\n");
exit(EXIT_FAILURE);

Meanwhile other errors in the same file correctly use fprintf(stderr):

// Line 332
fprintf(stderr, "Can't send EPG data\n");

Error messages should go to stderr so they are visible when stdout is
redirected (e.g. ccextractor input.ts > output.srt). With the current
code, network errors are silently swallowed in common usage.

Suggested Fix

  1. Remove #define DEBUG_OUT 0 and add CMake option:
option(NETWORKING_DEBUG "Enable networking debug output" OFF)
if(NETWORKING_DEBUG)
  add_definitions(-DNETWORKING_DEBUG)
endif()
  1. Replace all 3 printf( error calls with fprintf(stderr,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions