Skip to content

bug: library writes to stdout via stray printf in load_config_clean #109

Open

Description

@grzanka

Part of #108 (health-review epic).

Problem

src/dedx.c, in load_config_clean(), contains a debug leftover:

if (config->elements_length == 0) {
    printf("error \n");
    *err = DEDX_ERR_TARGET_NOT_FOUND;
    return -1;
}

A library must never write to stdout. Any consumer that uses stdout as a data channel (CLI pipes, the WASM build, scripts) can have its output corrupted by this stray line. The printf also adds no diagnostic value — the error is already reported through *err.

Steps to reproduce

Call the API with a custom-compound configuration (target resolves to a compound not found in the embedded data) such that dedx_internal_evaluate_compound() yields elements_length == 0, then observe error printed to stdout while *err is set to DEDX_ERR_TARGET_NOT_FOUND.

Expected

No output on stdout; the error is communicated solely via *err / the return value.

Proposed change

Delete the printf("error \n"); line. (Optionally route genuine diagnostics through a caller-controlled callback in a separate issue — out of scope here.)

Acceptance criteria

  • No printf/fprintf(stdout, …) calls remain in src/dedx.c.
  • The not-found path still sets *err = DEDX_ERR_TARGET_NOT_FOUND and returns -1.
  • grep -rn "printf" src/ | grep -v embedded/ returns nothing in non-test code.

Good first issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions