Hi all,
i have done a first quick test with lint over the
OpenOcd-Sources (based on commit 74ce435d97ca4f6f81645d755d04123f075aa42b)
from today.
Lint report a truckload of problems.
The first thing i had to learn was, that it is verry uncommon
in OpenOCD to check the result of malloc.
Here is a quick list of only a handfull of files
that don't check the result of malloc against NULL.
(L stands for line):
mflash.c: L 352
nand/core.c: L501, L616, 653
fileio.c: L83, L98
lpc3180.c: L53, L518, L519, L652, L653, L657, L658
aduc702x.c: L57, L77
at91sam7c: L536, L539, L555, L642, L738, L789, L792, L808, L876
arvf.c: L193, L309
cfi.c: L321, L387, L453, L616, L1453, L2309, L2385, L2402
nir/core.c: L204, L374, L437
nor/ecos.c: L134, L175
faux.c: L70, L58: pointer info is checked twice instead of info->memory
lpc2000.c: L73, L86, L157, L211, L436, L663
lpc288x.c: L141, L179
lpc2900.c: L1017, L1693
non_cfi.c: L477
ocl.c: L62, L153
pic32_mx.c: L76, L611
stellaris.c: L612
stm32x.c: L48, L761
... to be continued....given up
Lint also reports "out of bound" pointer access.
I think i have found some uninitalised pointers,
but have to go deeper in that before reporting
this.
Before i do anything, i want to know if the
OpenOcd Developers are interested in improving
the code for better maintainance. Make it (from my sight)
more maintainable and secure. The problem is, that it is pretty hard
to extract the real errors from the 10000 of messages lint
produce. It's like fixing only some special compiler errors and
leave the rest alone.
Clearing means e. g.:
- Clear the tripple include of stdio in ercosboard.c
- Change if (... && ((cmd == SLB) | (cmd == CLB)) to
if(.... && ((cmd == SLB) || (cmd == CLB))
- Use unsigned variables for unsigned data like
size, count, length, positive offsets...
- Use xU for unsigned constants.
- Check implicit cast (uint32_t -> uint16_t)
- Increase unambiguousness: n = last - first +1 or
imaginär example a*b+c-d*25<<3.
Let me know, what you think.
Best Regards,
Carsten_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development