text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE563_Unused_Variable__unused_uninit_variable_wchar_t_04.c
  Label Definition File: CWE563_Unused_Variable__unused_uninit_variable.label.xml
  Template File: source-sinks-04.tmpl.c
  */
  /*
   * @description
   * CWE: 563 Unused Variable
   * BadSource:  Initialize data
   * Sinks:
   *    GoodSink: Initialize, then use data
   *    BadSink : Do nothing
   * Flow Variant: 04 Control flow: if(static_const_t) and if(static_const_f)
   *
   * */
  
  #include "std_testcase.h"
  
  #include <wchar.h>
  
  /* The two variables below are declared "const", so a tool should
     be able to identify that reads of these will always return their
     initialized values. */
  static const int static_const_t = 1; /* true */
  static const int static_const_f = 0; /* false */
  
  #ifndef OMITBAD
  
  void CWE563_Unused_Variable__unused_uninit_variable_wchar_t_04_bad()
  {
      wchar_t data;
      /* POTENTIAL FLAW: Do not initialize or use data */
      ; /* empty statement needed for some flow variants */
      if(static_const_t)
      {
          /* POTENTIAL FLAW: Do not use the variable */
          /* do nothing */
          ; /* empty statement needed for some flow variants */
      }
      else
      {
          /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
          /* FIX: Initialize then use data */
          data = L'W';
          printf("%02lx\n", data);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodB2G1() - use badsource and goodsink by changing static_const_t to static_const_f */
  static void goodB2G1()
  {
      wchar_t data;
      /* POTENTIAL FLAW: Do not initialize or use data */
      ; /* empty statement needed for some flow variants */
      if(static_const_f)
      {
          /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
          /* POTENTIAL FLAW: Do not use the variable */
          /* do nothing */
          ; /* empty statement needed for some flow variants */
      }
      else
      {
          /* FIX: Initialize then use data */
          data = L'W';
          printf("%02lx\n", data);
      }
  }
  
  /* goodB2G2() - use badsource and goodsink by reversing statements in if  */
  static void goodB2G2()
  {
      wchar_t data;
      /* POTENTIAL FLAW: Do not initialize or use data */
      ; /* empty statement needed for some flow variants */
      if(static_const_t)
      {
          /* FIX: Initialize then use data */
          data = L'W';
          printf("%02lx\n", data);
      }
      else
      {
          /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
          /* POTENTIAL FLAW: Do not use the variable */
          /* do nothing */
          ; /* empty statement needed for some flow variants */
      }
  }
  
  void CWE563_Unused_Variable__unused_uninit_variable_wchar_t_04_good()
  {
      goodB2G1();
      goodB2G2();
  }
  
  #endif /* OMITGOOD */
  
  /* Below is the main(). It is only used when building this testcase on
     its own for testing or for building a binary to use in testing binary
     analysis tools. It is not used when compiling all the testcases as one
     application, which is how source code analysis tools are tested. */
  
  #ifdef INCLUDEMAIN
  
  int main(int argc, char * argv[])
  {
      /* seed randomness */
      srand( (unsigned)time(NULL) );
  #ifndef OMITGOOD
      printLine("Calling good()...");
      CWE563_Unused_Variable__unused_uninit_variable_wchar_t_04_good();
      printLine("Finished good()");
  #endif /* OMITGOOD */
  #ifndef OMITBAD
      printLine("Calling bad()...");
      CWE563_Unused_Variable__unused_uninit_variable_wchar_t_04_bad();
      printLine("Finished bad()");
  #endif /* OMITBAD */
      return 0;
  }
  
  #endif
  