Skip to content

Commit

Permalink
UBI: eliminate possible undefined behaviour
Browse files Browse the repository at this point in the history
The assignment to pos when rb is finally NULL is undefined behaviour.
Upon seeing that assignment, GCC may assume that rb is not NULL, and
the loop condition ``rb'' may be optimised away.

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
  • Loading branch information
Phil Carmody authored and Artem Bityutskiy committed Aug 14, 2009
1 parent 4a40685 commit 758d8e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mtd/ubi/ubi.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ void ubi_do_get_volume_info(struct ubi_device *ubi, struct ubi_volume *vol,
for (rb = rb_first(root), \
pos = (rb ? container_of(rb, typeof(*pos), member) : NULL); \
rb; \
rb = rb_next(rb), pos = container_of(rb, typeof(*pos), member))
rb = rb_next(rb), \
pos = (rb ? container_of(rb, typeof(*pos), member) : NULL))

/**
* ubi_zalloc_vid_hdr - allocate a volume identifier header object.
Expand Down

0 comments on commit 758d8e4

Please sign in to comment.