[RISC-V] Avoid unnecessary extensions when value is already extended
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / null-deref-pr108400-SoftEtherVPN-WebUi.c
blob9dcf7aa31f1018910e9e26ef53333825345e9a6b
1 /* Reduced from SoftEtherVPN's src/Cedar/WebUI.c. */
2 /* { dg-additional-options "-Wno-analyzer-symbol-too-complex" } */
4 #include "../../gcc.dg/analyzer/analyzer-decls.h"
5 typedef int (COMPARE)(void *p1, void *p2);
6 typedef unsigned int UINT;
7 typedef unsigned long int UINT64;
8 typedef struct LIST LIST;
9 typedef struct STRMAP_ENTRY STRMAP_ENTRY;
10 typedef struct WEBUI
12 /* [...snip...] */
13 LIST *Contexts;
14 } WEBUI;
16 typedef struct WU_CONTEXT
18 /* [...snip...] */
19 UINT64 ExpireDate;
20 } WU_CONTEXT;
22 struct LIST
24 /* [...snip...] */
25 UINT num_item, num_reserved;
26 void **p;
27 /* [...snip...] */
30 #define LIST_DATA(o, i) (((o) != NULL) ? ((o)->p[(i)]) : NULL)
31 #define LIST_NUM(o) (((o) != NULL) ? (o)->num_item : 0)
32 #ifdef __cplusplus
33 #ifndef _Bool
34 typedef bool _Bool;
35 #endif
36 #endif
38 struct STRMAP_ENTRY
40 char *Name;
41 void *Value;
44 void Free(void *addr);
45 void Add(LIST *o, void *p);
46 _Bool Delete(LIST *o, void *p);
47 void LockList(LIST *o);
48 void UnlockList(LIST *o);
49 void ReleaseList(LIST *o);
50 LIST *NewList(COMPARE *cmp);
51 UINT64 Tick64();
52 void WuFreeContext(WU_CONTEXT *context);
54 void WuExpireSessionKey(WEBUI *wu)
56 LIST *Expired = NewList(NULL);
57 UINT i;
59 LockList(wu->Contexts);
61 for(i=0; i<LIST_NUM(wu->Contexts); i++)
63 STRMAP_ENTRY *entry = (STRMAP_ENTRY*)LIST_DATA(wu->Contexts, i);
64 WU_CONTEXT *context = (WU_CONTEXT*)entry->Value; /* { dg-bogus "dereference of NULL 'entry'" "PR analyzer/108400" { xfail *-*-* } } */
65 if(context->ExpireDate < Tick64())
67 Add(Expired, entry);
71 for(i=0; i<LIST_NUM(Expired); i++)
73 STRMAP_ENTRY *entry = (STRMAP_ENTRY*)LIST_DATA(Expired, i);
74 Delete(wu->Contexts, entry);
75 Free(entry->Name);
76 WuFreeContext((WU_CONTEXT*)entry->Value);
77 Free(entry);
79 ReleaseList(Expired);
81 UnlockList(wu->Contexts);