unsigned radar11369570_hanging(const unsigned char *arr, int l) { unsigned a, b, c; a = b = c = 0x9899e3 + l; while (l >= 6) { unsigned t; scanf("%d", &t); a += b; a ^= a; a += (arr[3] + ((unsigned) arr[2] << 8) + ((unsigned) arr[1] << 16) + ((unsigned) arr[0] << 24)); longcmp(a, t, c); l -= 12; } return 5/a; // expected-warning {{Division by a tainted value, possibly zero}} }
// prints each series in the hash, also stores a pointer // for each series indexed by the order printed in eps_ptr static void print_menu(Eps** eps_ptr, Eps *hash ) { sqlite3 *db; int result; result = sqlite3_open(DATABASE, &db); if( result ) { efprintf("show_menu failed: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); exit(23); } sqlite3_stmt *statement_h; const char *query_h = "select current from SeriesData where Title = ?"; sqlite3_prepare_v2(db, query_h, (int) strlen(query_h), &statement_h, NULL); int index =0; // Prints each series of a separate row for(Eps *e=hash; e != NULL; e=e->hh.next, ++index) { // uses a array indexing index to series then use that to select the right series eps_ptr[index] = e; bool ordered = true; qsort_b(e->eps->arr, e->eps->index, sizeof(size_t), ^(const void *a, const void *b){ const Ep *ea = *((Ep**)a), *eb = *((Ep**)b); mmprintf("%ld %ld res: %d\n", ea->num, eb->num, longcmp( ea->num, eb->num ) ); return longcmp( ea->num , eb->num ); } ); if (e->eps->index > 1){ for(int i = 0; i<e->eps->index-1;i++){ if (EPS_ARR(e,i+1)->num != 1 + EPS_ARR(e,i)->num){ ordered = false; break; } } } sqlite3_bind_text(statement_h, 1, e->series, -1, SQLITE_TRANSIENT); result = sqlite3_step(statement_h); mmprintf("r:%i Row:%i Ok:%i done:%i \n", result, SQLITE_ROW, SQLITE_OK, SQLITE_DONE ); int current =-1; if (result == SQLITE_ROW|| result == SQLITE_OK || result == SQLITE_DONE){ current = sqlite3_column_int(statement_h, 0); mmprintf("current:%d\n",current ); }else{ efprintf( "SQL error %s : %s\n", e->series, sqlite3_errmsg(db)); exit(12); } // Printing printf( SSS("%-2d") " :", COLOUR(index,GREEN)); printf(" P: " SSS("%-2d"), COLOUR(current,WHITE)); printf(" N: "); if (ordered && e->eps->index > 1 ){ // Range of eps printf(SSS("%4ld") SSS("-%-4ld"), COLOUR(EPS_ARR(e,0)->num, BLUE), COLOUR(EPS_ARR(e,e->eps->index-1)->num,BLUE) ); }else if (e->eps->index == 1){ // single ep const int extra = (3-1)*3; printf(SSS("%2ld") " %*s", COLOUR(EPS_ARR(e,0)->num, YELLOW), extra,"" ); }else{ // range with eps missing (only shows the fist three) const int min = e->eps->index < 3 ? e->eps->index :3; const int extra = (3-min)*3; for(int i = 0; i<min;i++){ printf(SSS("%2ld") " %*s", COLOUR(EPS_ARR(e,i)->num, RED), extra,"" ); } } printf(" %s\n", e->series); result = sqlite3_reset(statement_h); }