1  #define NULL ((void*)0)
       2  
       3  typedef unsigned char __uint8_t;
       4  typedef __uint8_t uint8_t;
       5  typedef char gchar;
       6  typedef void* gpointer;
       7  
       8  extern void g_free(gpointer mem);
       9  extern gchar* g_strdup(const gchar* str) __attribute__((__malloc__));
      10  
      11  static inline void
      12  g_autoptr_cleanup_generic_gfree(void* p)
      13  {
      14    void** pp = (void**)p;
      15    g_free(*pp); /* { dg-bogus "use of uninitialized value" } */
      16  }
      17  
      18  typedef struct Object Object;
      19  
      20  void
      21  error_setg_internal(const char* fmt,
      22  		    ...) __attribute__((__format__(gnu_printf, 1, 2)));
      23  void
      24  visit_type_str(const char* name, char** obj);
      25  typedef struct SpaprMachineState SpaprMachineState;
      26  
      27  extern uint8_t
      28  spapr_get_cap(SpaprMachineState* spapr, int cap);
      29  
      30  typedef struct SpaprCapPossible
      31  {
      32    int num;
      33    /* [...snip...] */
      34    const char* vals[];
      35  } SpaprCapPossible;
      36  
      37  typedef struct SpaprCapabilityInfo
      38  {
      39    const char* name;
      40    /* [...snip...] */
      41    int index;
      42    /* [...snip...] */
      43    SpaprCapPossible* possible;
      44    /* [...snip...] */
      45  } SpaprCapabilityInfo;
      46  
      47  void
      48  spapr_cap_get_string(SpaprMachineState* spapr,
      49  		     const char* name,
      50  		     SpaprCapabilityInfo* cap)
      51  {
      52    __attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char* val = NULL;
      53    uint8_t value = spapr_get_cap(spapr, cap->index);
      54  
      55    if (value >= cap->possible->num) {
      56      error_setg_internal("Invalid value (%d) for cap-%s",
      57  			value,
      58  			cap->name);
      59      return;
      60    }
      61  
      62    val = g_strdup(cap->possible->vals[value]);
      63  
      64    visit_type_str(name, &val);
      65  }