On Fri, Dec 16, 2016 at 09:25:44AM +0100, Christoph Hellwig wrote: > On Fri, Dec 16, 2016 at 11:28:51AM +1100, Dave Chinner wrote: > > > + /* > > > + * Clamp maxlen to the amount of free space available for the actual > > > + * extent allocation. > > > + */ > > > + if (available < (int)args->maxlen && !(flags & XFS_ALLOC_FLAG_CHECK)) { > > > + args->maxlen = available; > > > + ASSERT(args->maxlen > 0); > > > + } > > > > I'd love to get rid of all these (int) casts, too... > > The problem here is that we compare 32-bit signed to 32-bit unsigned > variables. And given that this is ripe for nasty bugs due to the C > type promotion rules I'd rather be extra careful. Yes, I know - it's bitten me several times in the past. The underlying problem (IMO) is using xfs_extlen_t for things that aren't physical BMBT extent lengths, which are bound to: #define MAXEXTLEN ((xfs_extlen_t)0x001fffff) /* 21 bits */ but it's grown to be used for everything that needs to store or operate on the length of an extent. Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html