Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3091

debug_abort_if_reached macro

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.15.0
    • Component/s: None
    • Labels:
      None

      Description

      In some parts of our codebase, we have asserts and ProgramminError's which may happen in release builds. Usually because of weird policy or network input.

      I think assert and ProgrammingError should only be reserved for situations which should never happen, not even when a client sends some bad data.

      For those situations, we should introduce a new macro, for example:

      bool handle_data(const char *data)
      {
          assert(data != NULL); // Should never happen
      
          if (strlen(data) == 0)
          {
              debug_abort_if_reached(); // Abort here, should not happen in tests
              return false;
          }
      
          // Handle data
      
          return true;
      }
      

        Attachments

          Release management

            Activity

              People

              Assignee:
              olehermanse Ole Herman Schumacher Elgesem
              Reporter:
              olehermanse Ole Herman Schumacher Elgesem
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: