remarkable-linux/lib
Peter Lund 430d275a39 avoid negative (and full-width) shifts in radix-tree.c
Negative shifts are not allowed in C (the result is undefined).  Same thing
with full-width shifts.

It works on most platforms but not on the VAX with gcc 4.0.1 (it results in an
"operand reserved" fault).

Shifting by more than the width of the value on the left is also not
allowed.  I think the extra '>> 1' tacked on at the end in the original
code was an attempt to work around that.  Getting rid of that is an extra
feature of this patch.

Here's the chapter and verse, taken from the final draft of the C99
standard ("6.5.7 Bitwise shift operators", paragraph 3):

  "The integer promotions are performed on each of the operands. The
  type of the result is that of the promoted left operand. If the
  value of the right operand is negative or is greater than or equal
  to the width of the promoted left operand, the behavior is
  undefined."

Thank you to Jan-Benedict Glaw, Christoph Hellwig, Maciej Rozycki, Pekka
Enberg, Andreas Schwab, and Christoph Lameter for review.  Special thanks
to Andreas for spotting that my fix only removed half the undefined
behaviour.

Signed-off-by: Peter Lund <firefly@vax64.dk>
Christoph Lameter <clameter@sgi.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Andreas Schwab <schwab@suse.de>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: WU Fengguang <wfg@mail.ustc.edu.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-17 08:42:56 -07:00
..
lzo lzo: add some missing casts 2007-07-31 15:39:37 -07:00
reed_solomon
zlib_deflate
zlib_inflate [ZLIB]: Fix external builds of zlib_inflate code. 2007-10-11 22:17:20 -07:00
.gitignore
argv_split.c argv_split: allow argv_split to handle NULL pointer in argcp parameter gracefully 2007-10-17 08:42:50 -07:00
audit.c [PATCH] audit signal recipients 2007-05-11 05:38:25 -04:00
bitmap.c
bitrev.c
bug.c generic bug: use show_regs() instead of dump_stack() 2007-07-16 09:05:51 -07:00
bust_spinlocks.c handle recursive calls to bust_spinlocks() 2007-10-17 08:42:56 -07:00
check_signature.c uninline check_signature() 2007-07-16 09:05:50 -07:00
cmdline.c
cpumask.c
crc-ccitt.c
crc-itu-t.c
crc7.c CRC7 support 2007-07-17 10:23:04 -07:00
crc16.c
crc32.c
crc32defs.h
ctype.c
debug_locks.c
dec_and_lock.c
devres.c
div64.c
dump_stack.c
extable.c
fault-inject.c fault_inject: silence a warning 2007-07-24 12:24:59 -07:00
find_next_bit.c
gen_crc32table.c
genalloc.c Slab allocators: Replace explicit zeroing with __GFP_ZERO 2007-07-17 10:23:02 -07:00
halfmd4.c
hexdump.c hex_dump: add missing "const" qualifiers 2007-08-11 15:47:41 -07:00
hweight.c
idr.c Slab API: remove useless ctor parameter and reorder parameters 2007-10-17 08:42:45 -07:00
inflate.c
int_sqrt.c
iomap.c PCI: Document pci_iomap() 2007-08-22 14:48:40 -07:00
iomap_copy.c
ioremap.c lib/ioremap.c should #include <linux/io.h> 2007-10-17 08:42:50 -07:00
irq_regs.c
kasprintf.c lib: move kasprintf to a separate file 2007-07-31 15:39:39 -07:00
Kconfig Introduce CONFIG_CHECK_SIGNATURE 2007-08-22 19:52:45 -07:00
Kconfig.debug slow down printk during boot 2007-10-16 09:42:49 -07:00
kernel_lock.c
klist.c
kobject.c kobject: update the copyrights 2007-10-12 14:51:12 -07:00
kobject_uevent.c Driver core: kerneldoc - kobject_uevent_env is not "usually KOBJ_MOVE" 2007-10-12 14:51:06 -07:00
kref.c
libcrc32c.c
list_debug.c
locking-selftest-hardirq.h
locking-selftest-mutex.h
locking-selftest-rlock-hardirq.h
locking-selftest-rlock-softirq.h
locking-selftest-rlock.h
locking-selftest-rsem.h
locking-selftest-softirq.h
locking-selftest-spin-hardirq.h
locking-selftest-spin-softirq.h
locking-selftest-spin.h
locking-selftest-wlock-hardirq.h
locking-selftest-wlock-softirq.h
locking-selftest-wlock.h
locking-selftest-wsem.h
locking-selftest.c
Makefile lib: floating proportions 2007-10-17 08:42:45 -07:00
parser.c
percpu_counter.c lib: percpu_counter_init_irq 2007-10-17 08:42:44 -07:00
plist.c
prio_tree.c
proportions.c lib: floating proportions 2007-10-17 08:42:45 -07:00
radix-tree.c avoid negative (and full-width) shifts in radix-tree.c 2007-10-17 08:42:56 -07:00
random32.c
rbtree.c
reciprocal_div.c
rwsem-spinlock.c
rwsem.c
semaphore-sleepers.c
sha1.c
smp_processor_id.c
sort.c lib/sort.c optimization 2007-10-17 08:42:52 -07:00
spinlock_debug.c
string.c
swiotlb.c swiotlb: sg chaining support 2007-10-16 11:26:01 +02:00
textsearch.c
ts_bm.c
ts_fsm.c
ts_kmp.c
vsprintf.c lib: move kasprintf to a separate file 2007-07-31 15:39:39 -07:00