[CHECKER] mismatched error returning

From: Dawson Engler (engler@csl.Stanford.EDU)
Date: Fri Aug 11 2000 - 20:45:09 EDT

  • Next message: Dawson Engler: "[CHECKER]: malloc/free errors part III"

    Hi All,

    we have yet-another g++ extension that makes sure you return E* errors
    (ENODEV, ENOMEM, etc) either as negative ints or as positives ints but
    that you do not mix the two in a given function. It turned up a few
    cases in driver code of mixups. If this seems like a useful check, let
    us know and we can make it more robust. Also, if anyone knows of other
    similar checks that would be useful, we could add them.

    Dawson

    -----------------------------------------------------------------------
    /u2/engler/ic/linux-2.3.99/drivers/char/radio-cadet.c:578:cadet_init: ERROR: con
    flict: ret = (-22)
    /u2/engler/ic/linux-2.3.99/drivers/char/radio-cadet.c:583:cadet_init: ERROR: had
     1 returns > 1, 1 < 1

           if(io < 0) {
    #ifdef MODULE
                    printk(KERN_ERR "You must set an I/O address with io=0x???\n");
    #endif return EINVAL;
            }
            if(video_register_device(&cadet_radio,VFL_TYPE_RADIO)==-1) return -EINVAL;

    --------------------------------------------------------------------------

    /u2/engler/ic/linux-2.3.99/drivers/net/wan/sbni.c:411:sbni_probe1: ERROR: conflict: ret = (19)
    /u2/engler/ic/linux-2.3.99/drivers/net/wan/sbni.c:425:sbni_probe1: ERROR: conflict: ret = (11)
    /u2/engler/ic/linux-2.3.99/drivers/net/wan/sbni.c:439:sbni_probe1: ERROR: conflict: ret = (11)
    /u2/engler/ic/linux-2.3.99/drivers/net/wan/sbni.c:451:sbni_probe1: ERROR: conflict: ret = (-12)
    /u2/engler/ic/linux-2.3.99/drivers/net/wan/sbni.c:524:sbni_probe1: ERROR: had 3 returns > 1, 2 < 1

    if (check_region (ioaddr, SBNI_IO_EXTENT) < 0)
      return -ENODEV;

    if (version_printed++ == 0)
      printk (version);
            /* check for valid combination in CSR0 */
    csr0 = inb (ioaddr + CSR0);
    if (csr0 == 0xff || csr0 == 0)
      bad_card = 1;
    else
      {
        csr0 &= ~EN_INT;
        if (csr0 & BU_EMP)
          csr0 |= EN_INT;
        if ((VALID_DECODER & (1 << (csr0 >> 4))) == 0)
          bad_card = 1;
      }
    if (bad_card)
      return ENODEV;
    else
      outb (0, ioaddr + CSR0);

            ....

            if(autoirq == 0)
            {
                    printk("sbni probe at %#x failed to detect IRQ line\n", ioaddr);
                    return EAGAIN;
            }

            dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
            if(dev->priv == NULL)
            {
                    DP( printk("%s: cannot allocate memory\n", dev->name); )
                    return -ENOMEM;
            }
    -------------------------------------------------------------------------

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/



    This archive was generated by hypermail 2b29 : Fri Aug 11 2000 - 20:49:10 EDT