1// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s 2// expected-no-diagnostics 3 4typedef struct { 5 char I[4]; 6 int S; 7} Hdr; 8typedef struct { 9 short w; 10} Hdr2; 11typedef struct { 12 Hdr2 usedtobeundef; 13} Info; 14typedef struct { 15 const unsigned char *ib; 16 int cur; 17 int end; 18} IB; 19unsigned long gl(IB *input); 20inline void gbs(IB *input, unsigned char *buf, int count); 21void getB(IB *st, Hdr2 *usedtobeundef); 22inline unsigned char gb(IB *input) { 23 if (input->cur + 1 > input->end) 24 ; 25 return input->ib[(input->cur)++]; 26} 27static void getID(IB *st, char str[4]) { 28 str[0] = gb(st); 29 str[1] = gb(st); 30 str[2] = gb(st); 31 str[3] = gb(st); 32} 33static void getH(IB *st, Hdr *header) { 34 getID (st, header->I); 35 header->S = gl(st); 36} 37static void readILBM(IB *st, Info *pic) { 38 // Initialize field; 39 pic->usedtobeundef.w = 5; 40 41 // Time out in the function so that we will be forced to retry with no inlining. 42 Hdr header; 43 getH (st, &header); 44 getID(st, header.I); 45 int i = 0; 46 while (st->cur < st->end && i < 4) { 47 i++; 48 getH (st, &header); 49 } 50} 51int bitmapImageRepFromIFF(IB st, const unsigned char *ib, int il) { 52 Info pic; 53 st.ib = ib; 54 st.cur = 0; 55 st.end = il; 56 readILBM(&st,&pic); 57 return pic.usedtobeundef.w; // No undefined value warning here. 58} 59