Ugh, clearly the code is broken, so we don't want equivalent code, but
correct code. Use the unambiguous "MODINC(x,y) ((x) = ((x) + 1) % (y))"
form and not "have a bug that has properly defined behaviour under ANSI C".
Just looking at the code, it is fairly clear that the desire is to keep
q_in and q_out >= 0 and < I20_EVT_Q_LEN, which is the size of the event_q
array. With the buggy version, it is possible that you could have q_in or
q_out == I2O_EVT_Q_LEN, which is overflowing the array. Bad, bad, bad.
--- i2o_config.c.new Mon Oct 22 13:39:56 2001
+++ i2o_config.c.orig Tue Nov 27 16:03:19 2001
@@ -45,7 +45,7 @@
static spinlock_t i2o_config_lock = SPIN_LOCK_UNLOCKED;
struct wait_queue *i2o_wait_queue;
-#define MODINC(x,y) (x = x++ % y)
+#define MODINC(x,y) ((x) = ((x) + 1) % (y))
struct i2o_cfg_info
{
Cheers, Andreas
-- Andreas Dilger http://sourceforge.net/projects/ext2resize/ http://www-mddsp.enel.ucalgary.ca/People/adilger/- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/