text
stringlengths 110
791
|
---|
<s>[INST] find the error in this code: #include "c_standards.h"
static UINT_32 sda_064_1( void )
{ UINT_32 local_int; local_int = 0U; local_int++; return local_int;
} [/INST] The error is Local not initialised at declaration. |
<s>[INST] find the error in this code: #include "c_standards.h"
static void sda_065_1( void )
{ UINT_32 local_int = 1U; local_int++;
} [/INST] The error is Void function has no side effects. |
<s>[INST] find the error in this code: #include "c_standards.h"
extern UINT_16 sda_066_2( void );
static void sda_066( void )
{ SINT_32 loop; UINT_16 u8a = 0U; BOOL flag = FALSE; for( loop = 0; (loop < 10 ) && ( u8a != 42U ); ++loop ) { u8a = sda_066_2(); } for( loop = 0; (loop < 10 ) && flag; ++loop ) { u8a = sda_066_2(); flag = u8a != 42U; }
} [/INST] The error is Non boolean control variable modified in loop. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 global = 0U;
void sda_067_1( UINT_32 p1, UINT_32 p2 )
{ global = (global + p1) * p2;
}
void SDA_067( UINT_32 p3 )
{ sda_067_1( p3++, p3++ );
} [/INST] The error is Void function has global variable side effects. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_068_1( UINT_32 p1, UINT_32 p2 )
{ static UINT_32 var_1; var_1 = (var_1 + p1) * p2;
}
void SDA_068_2( UINT_32 p3 )
{ SDA_068_1( p3++, p3++ );
} [/INST] The error is Void function has persistent local side effects. |
<s>[INST] find the error in this code: #include "c_standards.h"
void sda_069 ( void )
{ UINT_32 var_1; var_1++;
} [/INST] The error is UR anomaly, variable used before assignment. |
<s>[INST] find the error in this code: #include "c_standards.h"
void static_061(SINT_32 p_1)
{ SINT_32 i = p_1; switch (p_1) { default: i++; } switch (p_1) { case 1: default: i++; }
} [/INST] The error is Switch contains default only. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
static void sda_070 ( const UINT_32 p1 )
{ UINT_32 var_1 = 0U; UINT_32 var_2 = p1; var_1++; if ( p1 > 42U ) { printf("%u\n", var_2); }
} [/INST] The error is DU anomaly, variable value is not used. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 arr[] = {1U, 2U, 3U};
static UINT_32 sda_072_2( UINT_32 * p2 )
{ (*p2)++; return 1U;
}
static void sda_072_1( UINT_32 idx )
{ UINT_32 p1; p1 = arr[idx] + sda_072_2( &idx );
} [/INST] The error is Potential side effect problem in expression. |
<s>[INST] find the error in this code: #include "c_standards.h"
static void SDA_073( void);
SINT_32 ss = 0;
SINT_32 st = 0;
static void SDA_073( void)
{ while( st > ss && (ss = 1) < 10 ){}
} [/INST] The error is Predicate variable modified in condition. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
static void SDA_075( void)
{ UINT_32 xx; FILE * fptr = fopen("mikes.h","rw"); fscanf(fptr,"%d",&xx ); if( xx == 0 ) { fptr = fopen("mikes.h","rw"); } else { }
} [/INST] The error is Attempt to open file pointer more than once. |
<s>[INST] find the error in this code: #include "c_standards.h"
static void SDA_076 ( void)
{ ;
}
SINT_32 main(void)
{
} [/INST] The error is Procedure is not called or referenced in code analysed. |
<s>[INST] find the error in this code: #include "c_standards.h"
struct tag
{ UCHAR * uptr;
};
static struct tag SDA_077 (void)
{ UCHAR loc = 42; struct tag rtag; rtag.uptr = &loc; return rtag;
} [/INST] The error is Local structure returned in function result. |
<s>[INST] find the error in this code: #include "c_standards.h"
static void SDA_078( void);
UCHAR glob=9;
static void SDA_078( void )
{ UCHAR loc; loc = glob;
}
int main(void)
{ SDA_078( );
} [/INST] The error is Global variable should be declared const. |
<s>[INST] find the error in this code: #include "c_standards.h"
static SINT_32 func(SINT_32 pp)
{ return pp;
}
static void SDA_080( void)
{ SINT_32 x; x = func(1);
} [/INST] The error is Potentially unused function-modified value. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
FILE * fptr;
static void SDA_081( void)
{ fptr = fopen("mikes.h","r"); remove("mikes.h"); fclose(fptr);
} [/INST] The error is Attempt to remove an open file. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
static void SDA_082( void)
{ FILE * fptr; struct {SINT_32 ff;}astr; fpos_t * anoffset = (fpos_t *)&astr; fptr = fopen("afile.h","w"); fsetpos(fptr,anoffset);
} [/INST] The error is fsetpos values not generated by fgetpos. |
<s>[INST] find the error in this code: #include "c_standards.h"
void static_62(SINT_32 p_1)
{ SINT_32 i = 0, j = 0; switch (p_1) { case 0: j = 0; case 1: j = i; break; default: i = j + 1; }
} [/INST] The error is Switch case not terminated with break. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
static void SDA_083( SINT_32 par );
SINT_32 ch;
FILE * fptr;
static void SDA_083( SINT_32 par )
{ if( par == 341 ) { ungetc(ch,fptr); } if( par > 0 ) { ungetc(ch,fptr); }
} [/INST] The error is Potentially repeated call to ungetc. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
#include <string.h>
static void SDA_084( void);
static void SDA_084( void)
{ int c,i; char data[256],append_data[256]; FILE *fp1; strcpy(append_data,"Some data to append"); fp1 = fopen("pf1.txt","a+"); c = getc(fp1); fwrite(append_data,256,1,fp1); if (c != 'o') { fread(data,256,1,fp1); } fclose (fp1);
} [/INST] The error is No fseek or flush before I/O. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
#include <string.h>
static void SDA_085( void)
{ char ok_file_name[256],bad_file_name1[256],bad_file_name2[256]; FILE *fp1,*fp2,*fp3; strcpy(ok_file_name,"/home/ldra.txt"); fp1 = fopen(ok_file_name,"w"); scanf("%s %s",bad_file_name1,bad_file_name2); if (strcmp(bad_file_name2,"bad_file.txt") != 0) { fp2 = fopen(bad_file_name1,"w"); fp3 = fopen(bad_file_name2,"w"); } fclose (fp1); fclose (fp2); fclose (fp3);
} [/INST] The error is Filename not verified before fopen. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
#include <string.h>
static void SDA_086( void)
{ char input_string1[256], input_string2[256]; scanf("%s %s",input_string1, input_string2); if (input_string2 != NULL) { fprintf(stderr, input_string1); }
} [/INST] The error is User input not checked before use. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
INT_32 glob_var;
volatile sig_atomic_t e_flag = 0;
void my_handler1(int signum)
{ glob_var = 99; fprintf(stderr,"Signal %d encountered\n",signum);
}
void my_handler2(int signum)
{ e_flag = 99; fprintf(stderr,"Signal %d encountered\n",signum);
}
void SDA_087(void)
{ signal(SIGINT, my_handler1); signal(SIGTERM,my_handler2);
} [/INST] The error is Illegal shared object in signal handler. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
static jmp_buf env;
static void my_handler1(int signum)
{ fprintf(stderr,"Signal %d encountered\n",signum); longjmp(env,1);
}
static void SDA_088(void)
{ setjmp(env); signal(SIGINT,my_handler1);
} [/INST] The error is Illegal use of longjmp in signal handler. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
static jmp_buf env;
void my_handler1(INT_32 signum)
{ fprintf(stderr,"Signal %d encountered\n",signum);
}
void my_handler2(INT_32 signum)
{ fprintf(stderr,"Signal %d encountered\n",signum); raise(SIGUSR1);
}
void SDA_089(void)
{ signal(SIGUSR1, my_handler1); signal(SIGINT, my_handler2);
} [/INST] The error is Signal called from within signal handler. |
<s>[INST] find the error in this code: #include <pthread.h>
#define NumOfThreads 2
int ind[] = {0, 1};
pthread_mutex_t mutexA;
static pthread_t TheThread[NumOfThreads];
void *funcA( void * arg );
void *funcB( void * arg );
int count = 0;
int main()
{ int i, status; pthread_create( &TheThread[0], NULL, funcA , &ind[0]); pthread_create( &TheThread[1], NULL, funcB , &ind[1]); for(i = 0; i < NumOfThreads; i++) { pthread_join(TheThread[i], (void **)&status ); }
}
void *funcA( void * arg )
{ pthread_mutex_lock(&mutexA); count++; pthread_mutex_unlock(&mutexA); return 0;
}
void *funcB( void * arg )
{ pthread_mutex_unlock(&mutexA); count++; pthread_mutex_lock(&mutexA); return 0;
} [/INST] The error is Unguarded global used in threaded function. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 glob_res = 0U;
static UINT_32 return_unsigned ( void )
{ return 4U;
}
static void SDA_091 ( UINT_32 x )
{ UINT_32 partused; partused = return_unsigned ( ); if ( x == 3 ) { glob_res = partused; }
} [/INST] The error is Function return value potentially unused. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_093 ( void )
{ UINT_32 local = 44U; use_uint(local);
} [/INST] The error is Local variable should be declared const. |
<s>[INST] find the error in this code: #include "c_standards.h"
void static_63()
{
} [/INST] The error is Empty parameter list to procedure/function. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 SDA_094( void )
{ UINT_32 v_1; UINT_32 v_2; v_1 = 0; return v_1;
} [/INST] The error is Named variable declared but not used in code. |
<s>[INST] find the error in this code: extern void gf1(void);
void (*gfptr)(void) = &gf1;
void SDA_095(void)
{ gfptr();
} [/INST] The error is Named global function pointer used in procedure. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_096( void )
{ UINT_32 v_1 = 0U; v_1 = 3U;
} [/INST] The error is Variable has repeated initialisation. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <signal.h>
#include <stdio.h>
static void my_handler2(INT_32 signum)
{ fprintf(stderr,"Signal %d encountered\n", signum);
}
static void my_handler1(INT_32 signum)
{ fprintf(stderr,"Signal %d encountered\n", signum); signal(SIGHUP, my_handler2);
}
static void SDA_097(void)
{ signal(SIGINT, my_handler1);
} [/INST] The error is Signal called from within signal handler. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
void SDA_098(void)
{ FILE *fp1; fp1 = fopen("file1.dat", "r"); fprintf(fp1, "Attempting to write to read-only file\n"); fclose(fp1);
} [/INST] The error is Attempt to write to file opened read only. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_099(INT32 *p, INT32 **pp1, INT32 **pp2)
{ INT_32 x; INT_32 *xp; x = *p; x = **pp1; xp = *pp2;
} [/INST] The error is Named pointer object used in procedure. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
#include <stdlib.h>
void SDA_103(void)
{ CHAR ch; FILE *fp1,*fp2; fp1 = fopen("file1.txt", "r"); ch = getc(fp1); if (ch != (INT_32)EOF) { fp2 = fopen("file1.txt","w"); } fclose (fp1); fclose (fp2);
} [/INST] The error is File opened both read and write. |
<s>[INST] find the error in this code: #include "c_standards.h"
struct not_opaque
{ INT_32 a; CHAR c;
};
typedef struct not_opaque *ptr_not_opaque;
typedef struct opaque *ptr_opaque;
void SDA_104(void)
{ struct opaque opq; struct not_opaque nopq; ptr_opaque p_ok1 = &opq; ptr_opaque p_ok2; ptr_not_opaque p_nok1; p_ok2 = p_ok1; p_nok1 = &nopq;
} [/INST] The error is Structure implementation not hidden. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
static void sda_105 ( const UINT_32 p1 )
{ UINT_32 var_1 = 0U; UINT_32 var_2 = p1; var_1++; if ( p1 > 42U ) { printf("%u\n", var_2); }
} [/INST] The error is DU anomaly dead code, var value is unused on all paths. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_106( INT_32 * par_1 )
{ *par_1 = 1;
} [/INST] The error is No prototype for non-static function. |
<s>[INST] find the error in this code: #include <setjmp.h>
#include "c_standards.h"
static void static_7(jmp_buf mark, SINT_32 val)
{ longjmp(mark,val);
} [/INST] The error is Jump out of procedure. |
<s>[INST] find the error in this code: #include "c_standards.h"
void foo(void)
{
}
void static_64(void)
{ CHAR x; x = (CHAR) foo();
} [/INST] The error is Void procedure used in expression. |
<s>[INST] find the error in this code: #include <stdlib.h>
#include <string.h>
void SDA_107( void )
{ char *error_str; char *buf = "extra_text"; error_str = getenv ("MY_VAR"); strcat(error_str, buf);
} [/INST] The error is Attempt to change system call capture string. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdlib.h>
extern void (*pfn)( );
#define GET_TAINTED_INT(val) \ do {const char *taint = getenv("TAINT_I"); \ if (taint == NULL) {taint = "42";} \ val = strtol(taint, 0, 10); \ } while (0);
void SDA_108(void)
{ INT_32 tainted; GET_TAINTED_INT(tainted) (*pfn)(tainted);
} [/INST] The error is Tainted argument to unprototyped func ptr. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
#include <stdlib.h>
#define GET_TAINTED_INT(val) \ do {const char *taint = getenv("TAINT_I"); \ if (taint == NULL) {taint = "42";} \ val = strtol(taint, 0, 10); \ } while (0);
void SDA_109(void)
{ INT_32 tainted; char buff[4]; GET_TAINTED_INT(tainted) (void) sprintf(buff, "%d", tainted);
} [/INST] The error is Tainted argument to formatted i/o function. |
<s>[INST] find the error in this code: #include "c_standards.h"
INT_32 fn(INT_32 a);
INT_32 fn(INT_32 a);
INT_32 fn(INT_32 a)
{ return a;
}
void sda_110( void )
{ INT_32 rc; rc = fn(0);
} [/INST] The error is More than one prototype for same function. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
void sda_111(const char *c_str)
{ char *endpt1 = NULL; UINT_64 num1 = strtoul(c_str, &endpt1 ,0); if ( endpt1 == c_str || (num1 == ULONG_MAX && errno == ERANGE) ) { ; } else { ; }
}
int main( int argc, char *argv[] )
{ sda_111("Hello");
} [/INST] The error is errno checked without having been set for errno setting fn. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdlib.h>
#include <stdio.h>
void sda_112(void)
{ INT_32 *x = (INT_32*)malloc(10 * sizeof(INT_32)); if (x == NULL) { fprintf(stderr, "malloc failure in %s\n", __func__); free(x); } else { x[0] = 1; } free(x);
}
int main( int argc, char *argv[] )
{ sda_112();
} [/INST] The error is Free called twice on same variable. |
<s>[INST] find the error in this code: #include <stdio.h>
void SDA_113(int p1)
{ FILE *fp1; fp1 = fopen("data1.txt","r"); if (p1 == 0) { fclose(fp1); } fclose(fp1);
} [/INST] The error is File closed more than once. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdlib.h>
#include <string.h>
void SDA_115(INT_32 *xfrom, UINT_32 sz)
{ UINT_32 xsize; const UINT_32 csize = 5U; INT_32 *yto = (INT_32 *)malloc(10 * sizeof(INT_32)); if (yto != NULL) { xsize = sz; memcpy(yto, xfrom, xsize * sizeof(INT_32)); memcpy(yto, xfrom, csize); }
} [/INST] The error is Copy length parameter not checked before use. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_118(INT_32 * p1)
{ *p1 = 77;
} [/INST] The error is Object changed via dereferenced pointer. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 glob = 0U;
void sda_119( UINT_32 * const ptr1, UINT_32 *ptr2, UINT_32 *ptr3 )
{ *ptr1 = 0; *ptr2 = 0; ptr3 = &glob;
} [/INST] The error is Pointer param should be declared const pointer. |
<s>[INST] find the error in this code: #include "c_standards.h"
void void_para_func(void P1)
{
}
void static_65( void )
{ void v_ptr; UINT_32 a; void_para_func(v_ptr); void_para_func((void)a);
} [/INST] The error is Void variable passed as parameter. |
<s>[INST] find the error in this code: #include "c_standards.h"
void sda_120( UINT_32 * pptr1, const UINT_32 * pptr2, UINT_32 * pptr3, UINT_32 arr1[ ], const UINT_32 arr2[ ] )
{ *pptr1 = *pptr2 + *pptr3; *pptr1 = arr1[0] + arr2[0];
} [/INST] The error is Pointer param should be declared pointer to const. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
void sda_121(const char *c_str)
{ char *endpt1 = NULL; unsigned long num1 = strtoul(c_str, &endpt1, 0);
}
int main( int argc, char *argv[] )
{ sda_121("Hello");
} [/INST] The error is errno neither set nor checked for errno setting function. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
void sda_122(const char *c_str)
{ char *endpt1 = NULL; errno = 0; unsigned long num1 = strtoul(c_str, &endpt1, 0);
}
int main( int argc, char *argv[] )
{ sda_122("Hello");
} [/INST] The error is errno not checked after being set for errno setting fn. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
void SDA_123( void )
{ FILE *f = fopen("file", "w"); fprintf(f, "hello world\n"); fclose(f);
} [/INST] The error is File pointer not checked for null before use. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
void sda_124( FILE *stream )
{ INT_32 in; INT_32 out; in = getc(stream); if ( in != EOF ) { (void)printf("Input char %c\n", (char)in); out = putc(in, stream); (void)printf("Output char %c\n", (char)out); }
} [/INST] The error is Var set by std lib func return not checked before use. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdlib.h>
void SDA_125(void)
{ INT_32 *ptr = 0; free(ptr);
} [/INST] The error is free called on variable with no allocated space. |
<s>[INST] find the error in this code: #include <stdio.h>
void SDA_126( void )
{ FILE *fp1; fclose(fp1);
} [/INST] The error is File closed that was never opened. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_127( SINT_32 num, SINT_32 val )
{ SINT_32 result; SINT_32 denom = val; result = num / denom; if ( denom != 0 ) { result = num / denom; }
} [/INST] The error is Local or member denominator not checked before use. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 *glob1;
UINT_32 *glob2;
void SDA_128(void)
{ UINT_32 loc = *glob1; UINT_32 loc2; if (glob2 != NULL) { loc2 = *glob2; }
} [/INST] The error is Global pointer not checked within this procedure. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
FILE *f1;
FILE *f2;
void SDA_129(void)
{ fprintf(f1, "hello world\n"); if (f2 != NULL) { fprintf(f2, "hello world\n"); }
} [/INST] The error is Global file pointer not checked within this procedure. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 static_66 ( void )
{ return;
} [/INST] The error is Function with empty return expression. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <stdio.h>
#include <stdlib.h>
SINT_32 glob1;
SINT_32 glob2;
void SDA_130(void)
{ glob1 = atoi("string 1"); printf("glob1 = %d", glob1); glob2 = atoi("string 2"); if (glob2 > 0) { printf("glob2 = %d", glob2); }
} [/INST] The error is Global set by std lib func return not checked before use. |
<s>[INST] find the error in this code: #include "c_standards.h"
SINT_32 glob1 = 1;
SINT_32 glob2 = 1;
void SDA_131(void)
{ SINT_32 loc1; SINT_32 loc2; loc1 = 2 / glob1; if (glob2 > 0) { loc2 = 2 / glob2; }
} [/INST] The error is Global denominator not checked within this procedure. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <errno.h>
#include <stdlib.h>
void SDA_132 ( void )
{ FLOAT_64 f64; errno = 0; f64 = atof ( "A.12" ); if ( errno == 0 ) { ; }
} [/INST] The error is errno checked after call to non-errno setting function. |
<s>[INST] find the error in this code: #include <stdio.h>
#include <locale.h>
#include <time.h>
void SDA_133( void )
{ char *ret_1; char *ret_2; ret_1 = setlocale ( LC_ALL, 0 ); ret_2 = setlocale ( LC_MONETARY, "French" ); ( void ) printf ( "%s\n", ret_1 );
}
static void SDA_133_B ( time_t *t )
{ char * time1 = asctime(localtime(t)); char * time2 = ctime(t); printf("%s", time1);
}
static void SDA_133_C( time_t *t )
{ struct tm * tmptr1 = gmtime(t); struct tm * tmptr2 = localtime(t); printf("%2d:%02d\n", (tmptr1->tm_hour)%24,tmptr1->tm_min);
}
static void SDA_133_D( time_t *t )
{ const char *res2; struct lconv *lc = localeconv(); res2 = setlocale ( lc, "French" ); printf ( "%s\n", lc->currency_symbol );
} [/INST] The error is Pointer from system function used after subsequent call. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <errno.h>
#include <stdlib.h>
extern void someFunction ( FLOAT_64 v );
void SDA_134 ( void )
{ char *endptr; FLOAT_64 value; errno = 0; value = strtod(str, &endptr); someFunction(value); if ( 0 != errno ) { }
} [/INST] The error is errno not checked before subsequent function call. |
<s>[INST] find the error in this code: #include "c_standards.h"
SINT_32 glob = 1;
void sda135(SINT_32 flag)
{ SINT_32 *ptr1 = NULL; SINT_32 *ptr2 = NULL; SINT_32 val; if (flag == 1) { ptr1 = &glob; ptr2 = &glob; } val = *ptr1; if (ptr2 != NULL) { val = *ptr2; }
} [/INST] The error is Global pointer assigned to NULL may be dereferenced. |
<s>[INST] find the error in this code: #include "c_standards.h"
SINT_32 glob = 1; SINT_32 *glob_ptr1 = NULL; SINT_32 *glob_ptr2 = NULL;
void sda135(SINT_32 flag)
{ SINT_32 val; if (flag == 1) { glob_ptr1 = &glob; glob_ptr2 = &glob; } val = *glob_ptr1; if (glob_ptr2 != NULL) { val = *glob_ptr2; }
} [/INST] The error is Global pointer assigned to NULL may be dereferenced. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_137(SINT_32 num, SINT_32 denom)
{ SINT_32 loc1; result = num / denom; if (denom != 0) { result = num / denom; } assert( denom != 0 ); result = num / denom;
} [/INST] The error is Parameter used as denominator not checked before use. |
<s>[INST] find the error in this code: #include <stdio.h>
#include <string.h>
void SDA_138(void)
{ char str[] = "This is a test"; memset(str, '-', 5); printf("%s", str);
} [/INST] The error is Third argument to memory function is an odd constant. |
<s>[INST] find the error in this code: #include "c_standards.h"
void SDA_139(SINT_32 *array, SINT_32 len, SINT_32 index)
{ SINT_32 value; if (index < len) { value = array[index]; } else { value = -1; }
} [/INST] The error is Incorrect array index validation. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <string.h>
void static_067(UINT_32 p_1)
{ UINT_32 local_x = 0;
#define BLOCKDEF "test" local_x = strlen(BLOCKDEF);
} [/INST] The error is #define used in a block. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define MAX_SIZE 64
void SDA_141( char * input )
{ if (strlen(input) > MAX_SIZE) { printf("Input string too long"); } else { UINT_32 index = 5U; UINT_32 i; char *buffer = (char *)malloc(MAX_SIZE); for (i = 0U; i < strlen(input); i++) { buffer[index++] = input[i]; } }
} [/INST] The error is Heap-based array index not checked before use. |
<s>[INST] find the error in this code: #include "c_standards.h"
static BOOL SDA_151( void )
{ BOOL flag; flag = FALSE; flag = TRUE; return flag;
}
static BOOL SDA_151_1( void )
{ BOOL flag = FALSE; flag = TRUE; return flag;
} [/INST] The error is DD data flow anomaly found. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 xref_1;
static void xref_001 ( void )
{ ;
} [/INST] The error is Declaration types do not match across a system. |
<s>[INST] find the error in this code: #include "c_standards.h"
SINT_32 xref_1; [/INST] The error is Declaration types do not match across a system. |
<s>[INST] find the error in this code: #include "c_standards.h"
UINT_32 xref_1;
SINT_32 xref_1;
void xref_002(void)
{
} [/INST] The error is Ambiguous declaration of variable. |
<s>[INST] find the error in this code: #include "c_standards.h"
SINT_32 g_var = 1; /* not compliant - g_var */
static void XREF_003( SINT_32 p_var )
{ SINT_32 result1 = p_var; /* not compliant - result1 */ SINT_32 result2; result2 = p_var; /* result2 later used, so compliant */ SINT_32 result3; result3 = result2; /* not compliant - result3 */
} [/INST] The error is Variable has only one use. |
<s>[INST] find the error in this code: #include "c_standards.h"
void foo(void);
void bar(void);
void bar(void)
{ struct stag_name { UINT_32 us1; UINT_32 us2; } sobj1; struct stag_name sobj2 = {1, 2};
}
void foo(void)
{ struct stag_name { SINT_32 ss1; CHAR ch1; } sobj3;
} [/INST] The error is Identifier reuse: struct/union tag repeated. |
<s>[INST] find the error in this code: #include "c_standards.h"
union utag_name
{ SINT_32 us1; CHAR us2;
} uobj1;
union utag_name uobj2 = {0};
static void xref_001(void)
{ struct utag_name { UINT_32 ss1; UINT_32 ss2; } sobj1;
} [/INST] The error is Identifier reuse: struct vs union. |
<s>[INST] find the error in this code: #include "c_standards.h"
void foo(void);
union utag_name
{ SINT_32 us1; CHAR us2;
} uobj1;
void foo(void)
{ enum utag_name { first, second } sobj1;
} [/INST] The error is Identifier reuse: struct/union tag vs enum tag. |
<s>[INST] find the error in this code: #include "c_standards.h"
#include <string.h>
#define BLOCKDEF "test"
void static_68(void)
{ UINT_32 local_x = 0U; local_x = strlen(BLOCKDEF);
}
#undef BLOCKDEF [/INST] The error is #undef used |
<s>[INST] find the error in this code: #include "c_standards.h"
void stag_name(void);
union stag_name
{ SINT_32 us1; CHAR us2;
} uobj1;
void stag_name(void)
{
} [/INST] The error is Identifier reuse: tag vs procedure. |
<s>[INST] find the error in this code: #include "c_standards.h"
void foo(UINT_32 utag_name);
union utag_name
{ SINT_32 us1; CHAR us2;
} uobj1;
void foo(UINT_32 utag_name)
{
} [/INST] The error is Identifier reuse: tag vs typedef. |
<s>[INST] find the error in this code: #include "c_standards.h"
void foo(void);
union utag_name
{ SINT_32 us1; CHAR us2;
} uobj1;
void foo(void)
{ UINT_32 utag_name;
} [/INST] The error is Identifier reuse: tag vs variable. |
<s>[INST] find the error in this code: #include "c_standards.h"
union utag_name
{ SINT_32 us1; CHAR us2;
} uobj1;
void xref_10(void)
{
utag_name: uobj1.us1 = 0;
} [/INST] The error is Identifier reuse: tag vs label (MR). |
<s>[INST] find the error in this code: #include "c_standards.h"
typedef double utag_name;
union utag_name
{ SINT_32 us1; CHAR us2;
} uobj1;
static void xref_011 ( void )
{
} [/INST] The error is Identifier reuse: tag vs typedef. |
<s>[INST] find the error in this code: #define s_tag2 sn1
#include "c_standards.h"
typedef struct s_tag
{ UINT_32 comp1; UINT_32 comp2;
} s_type; [/INST] The error is Identifier reuse: tag vs macro. |
<s>[INST] find the error in this code: #define s_tag sn2
#define u_tag sn3
#include "c_standards.h"
typedef struct s_tag2
{ UINT_32 comp3; UINT_32 comp4;
} s_type2;
typedef union u_tag
{ SINT_32 us1; CHAR us2;
} u_type;
void xref_012 ( void )
{ ;
} [/INST] The error is Identifier reuse: tag vs macro. |
<s>[INST] find the error in this code: #include "c_standards.h"
typedef struct stag_name
{ UINT_32 comp1; UINT_32 comp2;
} stag_type;
void foo(void);
void foo(void)
{ struct sloctag_name { UINT_32 stag_name; } sobj1;
} [/INST] The error is Identifier reuse: tag vs component. |
<s>[INST] find the error in this code: #include "c_standards.h"
typedef struct s_name1_tag
{ UINT_32 comp1; UINT_32 comp2;
} s_name1_type;
typedef enum e_name1_tag
{ first, s_name1_tag
} e_name1_type;
void foo(void);
void foo(void)
{
} [/INST] The error is Identifier reuse: tag vs enum constant. |
<s>[INST] find the error in this code: #include "c_standards.h"
void foo(void);
static UINT_32 static_var2;
void foo(void)
{ struct static_var2 { UINT_32 xx1; UINT_32 yy1; } ss1;
} [/INST] The error is Identifier reuse: persistent var vs tag. |
<s>[INST] find the error in this code: #include "c_standards.h"
#pragma MYERROR
static void static_69(void)
{ ;
} [/INST] The error is #pragma used. |
<s>[INST] find the error in this code: #include "c_standards.h"
typedef char t_name;
void foo(void);
void foo(void)
{ UINT_32 t_name;
} [/INST] The error is Identifier reuse: typedef vs variable. |
<s>[INST] find the error in this code: #include "c_standards.h"
void xref_17_1(void)
{ typedef char lab_name;
}
UINT_32 xref_17(void)
{ UINT_32 retval = 0;
lab_name: return retval;
} [/INST] The error is Identifier reuse: typedef vs label (MR). |
<s>[INST] find the error in this code: #include "c_standards.h"
void xref_018_1(void)
{ typedef double t_name; t_name local_var;
}
void xref_018(void)
{ typedef char t_name; t_name local_var;
} [/INST] The error is Identifier reuse: typedef vs typedef. |
<s>[INST] find the error in this code: #include "c_standards.h"
typedef char t_name;
void foo(UINT_32 t_name);
void foo(UINT_32 t_name)
{
} [/INST] The error is Identifier reuse: typedef vs procedure parameter. |
<s>[INST] find the error in this code: #include "c_standards.h"
typedef double static_var1;
void foo(void);
void foo(void)
{ static UINT_32 static_var1;
} [/INST] The error is Identifier reuse: persistent var vs typedef. |