Tomek CEDRO wrote:
>/ The new source code (after patching)  have 6 functions doing almost
/>/ the same: ft2232_init_ftd2xx(), ft2232_open_ftd2xx(),
/>/ ft2232_init_libftdi(), ft2232_open_libftdi(),  ft2232_init_sub(void),
/>/ ft2232_init() and the header update ;-)
/
Student code galore.

Did you read the patch comment, explaining the why we split the functions, or did you just comment the comment ...

Please comment the patch instead to give out-of-topic 'gratis' comment !

>/ I can understand that leaving allocated memory is bad. However there
/>/ is a simpler solution to the problem (patch attached) by only changing
/>/ few lines of existing code and leaving driver infrastructure/layout
/>/ common for all source code:
/>/ />/ ft2232_buffer_size = 0;
/>/      ft2232_buffer = malloc(FT2232_BUFFER_SIZE); <-- this is the bad malloc
/>/ />/ * for (;;){ />/ />/ * if (layout->init() != ERROR_OK) break; <-- we jump out on failure
/
Please just use goto to handle errors.
/*When we talk coding style with students, the first comment I have is :
DO NEVER USE GOTO STATEMENT BUT USE IF ELSE IF  ...
if( condition 1 )
statement1;
else if( condition 2 )
statement2;
else if( condition 3 )
statement3;
else
statement4;

The goto was for the unstructured languages ( as BASIC was ).

Sometimes goto is still used in complicated function to simplify the jump ... But the better should be to split your complicated function in sub functions ...

Anyway, this is out-of-topic .*/

//Peter
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to