On Wed, Dec 16, 2009 at 2:30 PM, Carsten Breuer <[email protected]> wrote: > 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.
This is a known problem where we gladly accept patches to fix each case. > 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. You will see by digging into the mailing list that we, the maintainers, are always very interested in cleaning up the code and that we gladly accept patches. If you have a patch that would allow others to run lint using an open source tool, then that would be well received. > Clearing means e. g.: > - Clear the tripple include of stdio in ercosboard.c I do cleanup of this file in batches. This file is my responsiblity. I'll fix this one for sure. > - 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. There may be some of these cases that are a matter of opinion or taste, but generally following lint warnings/notes is a good idea. -- Øyvind Harboe US toll free 1-866-980-3434 / International +47 51 63 25 00 http://www.zylin.com/zy1000.html ARM7 ARM9 ARM11 XScale Cortex JTAG debugger and flash programmer _______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
