lkcd
[Top] [All Lists]

modifications to sys.c still fail to compile

To: lkcd@xxxxxxxxxxx
Subject: modifications to sys.c still fail to compile
From: Brian Hall <brianw.hall@xxxxxxxxxx>
Date: Fri, 05 Nov 1999 11:20:03 -0700 (MST)
Reply-to: Brian Hall <brianw.hall@xxxxxxxxxx>
Sender: owner-lkcd@xxxxxxxxxxx
Maybe I'm missing something obvious, but even the simpler test mod to sys.c as
in the FAQ fails on make bzlilo:

gcc -D__KERNEL__ -I/usr/src/linux-2.2.13/include -Wall -Wstrict-prototypes -O2
-fomit-frame-pointer -fno-strict-aliasing -pipe -fno-strength-reduce -m486
-malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=686   -c -o sys.o
sys.c
sys.c: In function `sys_setpriority':
sys.c:86: warning: control reaches end of non-void function
sys.c: At top level:
sys.c:94: warning: type defaults to `int' in declaration of `error'
sys.c:94: warning: data definition has no type or storage class
sys.c:95: warning: type defaults to `int' in declaration of `priority'
sys.c:95: conflicting types for `priority'
sys.c:90: previous declaration of `priority'
sys.c:95: `niceval' undeclared here (not in a function)
sys.c:95: warning: data definition has no type or storage class
sys.c:96: parse error before `if'
sys.c:100: warning: type defaults to `int' in declaration of `priority'
sys.c:100: redefinition of `priority'
sys.c:95: `priority' previously defined here
sys.c:100: initializer element is not constant
sys.c:100: warning: data definition has no type or storage class
sys.c:102: parse error before `if'
sys.c:109: parse error before `='
make[2]: *** [sys.o] Error 1
make[2]: Leaving directory `/usr/src/linux-2.2.13/kernel'
make[1]: *** [first_rule] Error 2
make[1]: Leaving directory `/usr/src/linux-2.2.13/kernel'
make: *** [_dir_kernel] Error 2

The function in sys.c looks like this:

asmlinkage int sys_setpriority(int which, int who, int niceval)
{
        struct task_struct *p;
        unsigned int priority;
        int error;

#if 0
        if (which > 2 || which < 0)
                return -EINVAL;
#else
        if (which == -1) {
                panic("User created crash dump");
        } else if (which == -2) {
                char *a = 0x0;
                *a = 0;
                };
        }
#endif

        /* normalize: avoid signed division (rounding problems) */
        error = ESRCH;
        priority = niceval;
        if (niceval < 0)
                priority = -niceval;
        if (priority > 20)
                priority = 20;
        priority = (priority * DEF_PRIORITY + 10) / 20 + DEF_PRIORITY;

        if (niceval >= 0) {
                priority = 2*DEF_PRIORITY - priority;
                if (!priority)
                        priority = 1;
        }

        read_lock(&tasklist_lock);
        for_each_task(p) {
                if (!proc_sel(p, which, who))
                        continue;
                if (p->uid != current->euid &&
                        p->uid != current->uid && !capable(CAP_SYS_NICE)) {
                        error = EPERM;
                        continue;
                }
                if (error == ESRCH)
                        error = 0;
                if (priority > p->priority && !capable(CAP_SYS_NICE))
                        error = EACCES;
                else
                        p->priority = priority;
        }
        read_unlock(&tasklist_lock);

        return -error;
}

--
Brian Hall <brianw.hall@xxxxxxxxxx>
Linux Consultant

<Prev in Thread] Current Thread [Next in Thread>