lkml.org 
[lkml]   [2004]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    SubjectRe: [2.6 patch][1/3] ipc/ BUG -> BUG_ON conversions
    Date
    On Aug 28, 2004, at 11:15, Adrian Bunk wrote:
    > The patch below does BUG -> BUG_ON conversions in ipc/ .
    > --- linux-2.6.9-rc1-mm1-full-3.4/ipc/shm.c.old 2004-08-28
    > 15:55:28.000000000 +0200
    > +++ linux-2.6.9-rc1-mm1-full-3.4/ipc/shm.c 2004-08-28
    > 16:02:56.000000000 +0200
    > @@ -86,8 +86,7 @@
    > static inline void shm_inc (int id) {
    > struct shmid_kernel *shp;
    >
    > - if(!(shp = shm_lock(id)))
    > - BUG();
    > + BUG_ON(!(shp = shm_lock(id)));

    This won't work:

    With debugging mode:
    if (unlikely(!(shp = shm_lock(id)))) BUG();

    Without debugging mode:
    do { } while(0)

    Anything you put in BUG_ON() must *NOT* have side effects.


    > shp->shm_atim = get_seconds();
    > shp->shm_lprid = current->tgid;
    > shp->shm_nattch++;
    > @@ -137,8 +136,7 @@
    >
    > down (&shm_ids.sem);
    > /* remove from the list of attaches of the shm segment */
    > - if(!(shp = shm_lock(id)))
    > - BUG();
    > + BUG_ON(!(shp = shm_lock(id)));

    Same here

    > shp->shm_lprid = current->tgid;
    > shp->shm_dtim = get_seconds();
    > shp->shm_nattch--;
    > @@ -744,8 +741,7 @@
    > up_write(&current->mm->mmap_sem);
    >
    > down (&shm_ids.sem);
    > - if(!(shp = shm_lock(shmid)))
    > - BUG();
    > + BUG_ON(!(shp = shm_lock(shmid)));

    And here

    > shp->shm_nattch--;
    > if(shp->shm_nattch == 0 &&
    > shp->shm_flags & SHM_DEST)

    Cheers,
    Kyle Moffett

    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.12
    GCM/CS/IT/U d- s++: a17 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$
    L++++(+++) E W++(+) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+
    PGP+++ t+(+++) 5 X R? tv-(--) b++++(++) DI+ D+ G e->++++$ h!*()>++$ r
    !y?(-)
    ------END GEEK CODE BLOCK------


    -
    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/
    \
     
     \ /
      Last update: 2005-03-22 14:05    [W:4.440 / U:0.468 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site