Skip to content

Dmod_VerifyAllApisSignatures: treat already-connected outputs as valid#289

Merged
JohnAmadis merged 3 commits intodevelopfrom
copilot/add-api-verification-check
Mar 9, 2026
Merged

Dmod_VerifyAllApisSignatures: treat already-connected outputs as valid#289
JohnAmadis merged 3 commits intodevelopfrom
copilot/add-api-verification-check

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

Dmod_VerifyAllApisSignatures reported an error for any output entry that wasn't a valid signature string — including entries that had already been connected (i.e., replaced with a live function pointer by Dmod_ConnectApi). This caused false negatives when verifying a partially- or fully-connected module.

Changes

src/system/public/dmod_dmf_api.c

  • Added static helper FindConnectedFunctionSignature(void*) that searches for a pointer in the system builtin inputs (Dmod_BuiltinInputApi) and all loaded module inputs (Dmod_Contexts[i]->Inputs), returning the matched entry's signature string (or NULL if not found).
  • Updated the output-entry loop in Dmod_VerifyAllApisSignatures: an entry that fails Dmod_ApiSignature_IsValid is now passed to the helper before being treated as an error.
    • Match found → VERBOSE log with the actual signature of the connected function; result stays true.
    • No match → existing ERROR path, result = false.
if( !Dmod_ApiSignature_IsValid( Context->Outputs.OutputSection->Entries[i] ) )
{
    const char* connectedSignature = FindConnectedFunctionSignature( Context->Outputs.OutputSection->Entries[i] );
    if( connectedSignature != NULL )
    {
        DMOD_LOG_VERBOSE("Output API at index %zu is already connected: %s\n", i, connectedSignature);
    }
    else
    {
        DMOD_LOG_ERROR("Invalid API signature in output API: %s\n", ...);
        result = false;
    }
}

tests/system/public/tests_dmod_verify_apis.cpp (new)

Eight unit tests covering: null context, empty sections, valid signatures, output already connected via builtin inputs, output already connected via loaded-module inputs, unknown pointer (must fail), invalid input signature (must fail), valid input signature.

tests/system/public/CMakeLists.txt

Registered the new test file.

Original prompt

This section details on the original issue you should resolve

<issue_title>Dodać weryfikowanie czy API jest poprawnie połączone w Dmod_VerifyAllApisSignatures</issue_title>
<issue_description>Aktualnie funkcja Dmod_VerifyAllApisSignatures sprawdza, czy sygnatury są poprawne - ale dobrze by było w przypadku, gdy zawartość nie wygląda na poprawną sygnaturę, sprawdzić czy to czasem nie jest już podłączone API - czyli porównać pointery z dostępnymi funkcjami w systemowych inputach i załadowanych modułach</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add API connection verification in Dmod_VerifyAllApisSignatures Dmod_VerifyAllApisSignatures: treat already-connected outputs as valid Mar 9, 2026
Copy link
Contributor

@JohnAmadis JohnAmadis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot popraw to - przerób tę funkcję tak, aby zwracała string z sygnaturą i użyj jej w logach

{
if( Dmod_BuiltinInputApi.InputSection->Entries[i].Function == Pointer )
{
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot zamiast zwracac po prostu true/false przerob te funkcje tak, aby zwracala sygnature jesli cos znajdzie

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in dc13b3c. Renamed to FindConnectedFunctionSignature — now returns const char* (the matched signature) or NULL if nothing is found.

result = false;
if( IsPointerAConnectedFunction( Context->Outputs.OutputSection->Entries[i] ) )
{
DMOD_LOG_WARN("Output API at index %zu is already connected (function: %p)\n", i, Context->Outputs.OutputSection->Entries[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tutaj bys mogl drukowac sygnature tej funkcji, ktora jest podlaczona uzywajac wynikow tego przeszukiwania, bo samo drukowanie informacji, ze ten pointer jest funkcja niewiele pomaga. Ponadto to nie powinien byc warning, tylko zwykle info/verbose, bo to nie jest nic zlego

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dc13b3c. The log now prints the actual signature returned by FindConnectedFunctionSignature, and the level is DMOD_LOG_VERBOSE.

…VERBOSE

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 9, 2026

@copilot popraw to - przerób tę funkcję tak, aby zwracała string z sygnaturą i użyj jej w logach

Refactored in dc13b3cFindConnectedFunctionSignature returns the signature string (or NULL), and that string is used directly in the DMOD_LOG_VERBOSE call.

@JohnAmadis JohnAmadis marked this pull request as ready for review March 9, 2026 20:09
@JohnAmadis JohnAmadis merged commit a83f323 into develop Mar 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dodać weryfikowanie czy API jest poprawnie połączone w Dmod_VerifyAllApisSignatures

2 participants