I am an intermediate C programmer. If you have made any coding mistake that you came to know later that it was the most hazardous / harmful to the total application please share
Two things comes to mind. Ths first was a function in embedded C (MCU) i tried to have some restrictions on an timer value as a entered a function. so I wrote
if(55000 < my_var < 65000)
My ida was to check like this:
if( (55000
But this is the equivilant or the result
if( (55000
and the result ended up that the if test was always true.
The secound was a pointer mistake. (simplyfied presented here)
get_data(BYTE **dataptr)
{
ubyte* data = malloc(10);
... code ...
*dataptr = &data[1];
}
main()
{
BYTE *data
get_data(&data);
free(data);
}
Thus resulting in a loss of 1 byte of memory for each time the get_data()
function was called