How to fix format not a string literal and no format arguments

  c++

The below code compiles and works fine, but it fails when passing Wformat-security in the options.

ACPI_STATUS
AcpiOsSignal(UINT32 function, void *info)
{
    DEBUG_FUNCTION();

    switch (function) {
        case ACPI_SIGNAL_FATAL:
#ifdef _KERNEL_MODE
            panic(info == NULL ? "AcpiOsSignal: fatal" : (const char*)info);
            break;
#endif
        case ACPI_SIGNAL_BREAKPOINT:
            if (info != NULL)
                AcpiOsPrintf("AcpiOsBreakpoint: %s ****n", (const char*)info);
            else
                AcpiOsPrintf("At AcpiOsBreakpoint ****n");
            break;
    }

    return AE_OK;
}

It fails with: error: format string literal and no format arguments on the closing parenthesis of the line.

panic(info == NULL ? "AcpiOsSignal: fatal" : (const char*)info);

Any ideas?

Source: Windows Questions C++

LEAVE A COMMENT