Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#2873 closed defect (fixed)

src/c/src/lib/libbsp/arm/raspberrypi/i2c/i2c.c:320: defective error checking ?

Reported by: David Binderman Owned by: Gedare Bloom <gedare@…>
Priority: normal Milestone: 5.1
Component: arch/arm Version: 4.11
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

src/c/src/lib/libbsp/arm/raspberrypi/i2c/i2c.c:320]: (style) Checking if unsigned variable 'rv' is less than zero.

Source code is

rv = rpi_i2c_setup_transfer(bus);

if ( rv < 0 ) {

but

uint32_t rv = 0;

and

static int rpi_i2c_setup_transfer(rpi_i2c_bus *bus)

Suggest put return value into an int local variable, then
sanity check it, then assign it to rv.

Change History (6)

comment:1 Changed on 01/19/17 at 20:35:03 by Gedare Bloom <gedare@…>

Owner: set to Gedare Bloom <gedare@…>
Resolution: fixed
Status: newclosed

In [changeset:"70e8abf3917c93ab085ca77fee379df9fa000183/rtems"]:

raspberrypi: use signed int for return variable

Closes #2873.

comment:2 Changed on 02/05/17 at 02:07:37 by Joel Sherrill

This ticket is closed but I would like to know what you are running to spot these issues and what settings.

I would like to make sure that eventually we are running the same thing as a project. I would have emailed directly but couldn't find your email.

Thanks.

--joel

comment:3 Changed on 02/05/17 at 09:06:38 by David Binderman

I would like to know what you are running to spot these issues and what settings.

I run a static C / C++ analyser called cppcheck, available from sourceforge.

http://cppcheck.sourceforge.net/

The latest released version would probably work ok, but I use the current development version.
I use flag --enable=all and I've tweeked the source of cppcheck as well.

BTW, if I could figure out how to build rtems on Linux, then I could run the latest
development versions of clang and gcc over rtems and possibly get some interesting warnings.

I would like to make sure that eventually we are running the same thing as a project.

I have been doing this myself for about a year or so. I'd be more than happy
to help and share my results.

I would have emailed directly but couldn't find your email.

dcb 314 at hotmail dot com. Feel free to chat offline.

comment:4 Changed on 05/11/17 at 07:31:02 by Sebastian Huber

Milestone: 4.124.12.0

comment:5 Changed on 10/16/17 at 06:24:30 by Sebastian Huber

Component: unspecifiedarch/arm

comment:6 Changed on 11/09/17 at 06:27:14 by Sebastian Huber

Milestone: 4.12.05.1

Milestone renamed

Note: See TracTickets for help on using tickets.