Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

flat: use IS_ERR_VALUE() helper macro

There is a common macro now for testing mixed pointer/errno values, so use
that rather than handling the casts ourself.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: David McCullough <david_mccullough@securecomputing.com>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mike Frysinger and committed by
Linus Torvalds
0b8c78f2 8e8b63a6

+10 -12
+10 -12
fs/binfmt_flat.c
··· 278 278 ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos); 279 279 if (ret <= 0) 280 280 break; 281 - if (ret >= (unsigned long) -4096) 282 - break; 283 281 len -= ret; 284 282 285 283 strm.next_in = buf; ··· 333 335 "(%d != %d)", (unsigned) r, curid, id); 334 336 goto failed; 335 337 } else if ( ! p->lib_list[id].loaded && 336 - load_flat_shared_library(id, p) > (unsigned long) -4096) { 338 + IS_ERR_VALUE(load_flat_shared_library(id, p))) { 337 339 printk("BINFMT_FLAT: failed to load library %d", id); 338 340 goto failed; 339 341 } ··· 543 545 textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, 544 546 MAP_PRIVATE|MAP_EXECUTABLE, 0); 545 547 up_write(&current->mm->mmap_sem); 546 - if (!textpos || textpos >= (unsigned long) -4096) { 548 + if (!textpos || IS_ERR_VALUE(textpos)) { 547 549 if (!textpos) 548 550 textpos = (unsigned long) -ENOMEM; 549 551 printk("Unable to mmap process text, errno %d\n", (int)-textpos); ··· 558 560 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); 559 561 up_write(&current->mm->mmap_sem); 560 562 561 - if (realdatastart == 0 || realdatastart >= (unsigned long)-4096) { 563 + if (realdatastart == 0 || IS_ERR_VALUE(realdatastart)) { 562 564 if (!realdatastart) 563 565 realdatastart = (unsigned long) -ENOMEM; 564 566 printk("Unable to allocate RAM for process data, errno %d\n", ··· 585 587 result = bprm->file->f_op->read(bprm->file, (char *) datapos, 586 588 data_len + (relocs * sizeof(unsigned long)), &fpos); 587 589 } 588 - if (result >= (unsigned long)-4096) { 590 + if (IS_ERR_VALUE(result)) { 589 591 printk("Unable to read data+bss, errno %d\n", (int)-result); 590 592 do_munmap(current->mm, textpos, text_len); 591 593 do_munmap(current->mm, realdatastart, data_len + extra); ··· 605 607 PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); 606 608 up_write(&current->mm->mmap_sem); 607 609 608 - if (!textpos || textpos >= (unsigned long) -4096) { 610 + if (!textpos || IS_ERR_VALUE(textpos)) { 609 611 if (!textpos) 610 612 textpos = (unsigned long) -ENOMEM; 611 613 printk("Unable to allocate RAM for process text/data, errno %d\n", ··· 639 641 fpos = 0; 640 642 result = bprm->file->f_op->read(bprm->file, 641 643 (char *) textpos, text_len, &fpos); 642 - if (result < (unsigned long) -4096) 644 + if (!IS_ERR_VALUE(result)) 643 645 result = decompress_exec(bprm, text_len, (char *) datapos, 644 646 data_len + (relocs * sizeof(unsigned long)), 0); 645 647 } ··· 649 651 fpos = 0; 650 652 result = bprm->file->f_op->read(bprm->file, 651 653 (char *) textpos, text_len, &fpos); 652 - if (result < (unsigned long) -4096) { 654 + if (!IS_ERR_VALUE(result)) { 653 655 fpos = ntohl(hdr->data_start); 654 656 result = bprm->file->f_op->read(bprm->file, (char *) datapos, 655 657 data_len + (relocs * sizeof(unsigned long)), &fpos); 656 658 } 657 659 } 658 - if (result >= (unsigned long)-4096) { 660 + if (IS_ERR_VALUE(result)) { 659 661 printk("Unable to read code+data+bss, errno %d\n",(int)-result); 660 662 do_munmap(current->mm, textpos, text_len + data_len + extra + 661 663 MAX_SHARED_LIBS * sizeof(unsigned long)); ··· 833 835 834 836 res = prepare_binprm(&bprm); 835 837 836 - if (res <= (unsigned long)-4096) 838 + if (!IS_ERR_VALUE(res)) 837 839 res = load_flat_file(&bprm, libs, id, NULL); 838 840 839 841 abort_creds(bprm.cred); ··· 878 880 stack_len += FLAT_DATA_ALIGN - 1; /* reserve for upcoming alignment */ 879 881 880 882 res = load_flat_file(bprm, &libinfo, 0, &stack_len); 881 - if (res > (unsigned long)-4096) 883 + if (IS_ERR_VALUE(res)) 882 884 return res; 883 885 884 886 /* Update data segment pointers for all libraries */