do-nothing code in sysv_shm.c

Divacky Roman xdivac02 at stud.fit.vutbr.cz
Tue Apr 12 08:10:25 PDT 2005


On Mon, Apr 11, 2005 at 08:03:24PM +0400, Vladislav Shabanov wrote:
> I`ve found the following code in sysv_shm.c :
> 
> ............
> static void
> shminit()
> {
>         int i;
> 
>         TUNABLE_INT_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall);
>         for (i = PAGE_SIZE; i > 0; i--) {
>                 shminfo.shmmax = shminfo.shmall * PAGE_SIZE;
>                 if (shminfo.shmmax >= shminfo.shmall)
>                         break;
>         }
>         TUNABLE_INT_FETCH("kern.ipc.shmmin", &shminfo.shmmin);
> .........
> 
> IMHO, loop does nothing. Possible variant:

alfred perlstein commited this saying:
Bring shm functions closer the the opengroup standards.

he is the person you should ask why is it coded this way. imho compiler just
optimizes this out leaving plain shminfo.shmmax = shminfo.shmall * PAGE_SIZE;

roman


More information about the freebsd-hackers mailing list