25 Jul, 2008

40 commits

  • This patch is by far the most complex in the series. It adds a new syscall
    paccept. This syscall differs from accept in that it adds (at the userlevel)
    two additional parameters:

    - a signal mask
    - a flags value

    The flags parameter can be used to set flag like SOCK_CLOEXEC. This is
    imlpemented here as well. Some people argued that this is a property which
    should be inherited from the file desriptor for the server but this is against
    POSIX. Additionally, we really want the signal mask parameter as well
    (similar to pselect, ppoll, etc). So an interface change in inevitable.

    The flag value is the same as for socket and socketpair. I think diverging
    here will only create confusion. Similar to the filesystem interfaces where
    the use of the O_* constants differs, it is acceptable here.

    The signal mask is handled as for pselect etc. The mask is temporarily
    installed for the thread and removed before the call returns. I modeled the
    code after pselect. If there is a problem it's likely also in pselect.

    For architectures which use socketcall I maintained this interface instead of
    adding a system call. The symmetry shouldn't be broken.

    The following test must be adjusted for architectures other than x86 and
    x86-64 and in case the syscall numbers changed.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include

    #ifndef __NR_paccept
    # ifdef __x86_64__
    # define __NR_paccept 288
    # elif defined __i386__
    # define SYS_PACCEPT 18
    # define USE_SOCKETCALL 1
    # else
    # error "need __NR_paccept"
    # endif
    #endif

    #ifdef USE_SOCKETCALL
    # define paccept(fd, addr, addrlen, mask, flags) \
    ({ long args[6] = { \
    (long) fd, (long) addr, (long) addrlen, (long) mask, 8, (long) flags }; \
    syscall (__NR_socketcall, SYS_PACCEPT, args); })
    #else
    # define paccept(fd, addr, addrlen, mask, flags) \
    syscall (__NR_paccept, fd, addr, addrlen, mask, 8, flags)
    #endif

    #define PORT 57392

    #define SOCK_CLOEXEC O_CLOEXEC

    static pthread_barrier_t b;

    static void *
    tf (void *arg)
    {
    pthread_barrier_wait (&b);
    int s = socket (AF_INET, SOCK_STREAM, 0);
    struct sockaddr_in sin;
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
    sin.sin_port = htons (PORT);
    connect (s, (const struct sockaddr *) &sin, sizeof (sin));
    close (s);

    pthread_barrier_wait (&b);
    s = socket (AF_INET, SOCK_STREAM, 0);
    sin.sin_port = htons (PORT);
    connect (s, (const struct sockaddr *) &sin, sizeof (sin));
    close (s);
    pthread_barrier_wait (&b);

    pthread_barrier_wait (&b);
    sleep (2);
    pthread_kill ((pthread_t) arg, SIGUSR1);

    return NULL;
    }

    static void
    handler (int s)
    {
    }

    int
    main (void)
    {
    pthread_barrier_init (&b, NULL, 2);

    struct sockaddr_in sin;
    pthread_t th;
    if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
    {
    puts ("pthread_create failed");
    return 1;
    }

    int s = socket (AF_INET, SOCK_STREAM, 0);
    int reuse = 1;
    setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse));
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
    sin.sin_port = htons (PORT);
    bind (s, (struct sockaddr *) &sin, sizeof (sin));
    listen (s, SOMAXCONN);

    pthread_barrier_wait (&b);

    int s2 = paccept (s, NULL, 0, NULL, 0);
    if (s2 < 0)
    {
    puts ("paccept(0) failed");
    return 1;
    }

    int coe = fcntl (s2, F_GETFD);
    if (coe & FD_CLOEXEC)
    {
    puts ("paccept(0) set close-on-exec-flag");
    return 1;
    }
    close (s2);

    pthread_barrier_wait (&b);

    s2 = paccept (s, NULL, 0, NULL, SOCK_CLOEXEC);
    if (s2 < 0)
    {
    puts ("paccept(SOCK_CLOEXEC) failed");
    return 1;
    }

    coe = fcntl (s2, F_GETFD);
    if ((coe & FD_CLOEXEC) == 0)
    {
    puts ("paccept(SOCK_CLOEXEC) does not set close-on-exec flag");
    return 1;
    }
    close (s2);

    pthread_barrier_wait (&b);

    struct sigaction sa;
    sa.sa_handler = handler;
    sa.sa_flags = 0;
    sigemptyset (&sa.sa_mask);
    sigaction (SIGUSR1, &sa, NULL);

    sigset_t ss;
    pthread_sigmask (SIG_SETMASK, NULL, &ss);
    sigaddset (&ss, SIGUSR1);
    pthread_sigmask (SIG_SETMASK, &ss, NULL);

    sigdelset (&ss, SIGUSR1);
    alarm (4);
    pthread_barrier_wait (&b);

    errno = 0 ;
    s2 = paccept (s, NULL, 0, &ss, 0);
    if (s2 != -1 || errno != EINTR)
    {
    puts ("paccept did not fail with EINTR");
    return 1;
    }

    close (s);

    puts ("OK");

    return 0;
    }
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    [akpm@linux-foundation.org: make it compile]
    [akpm@linux-foundation.org: add sys_ni stub]
    Signed-off-by: Ulrich Drepper
    Acked-by: Davide Libenzi
    Cc: Michael Kerrisk
    Cc:
    Cc: "David S. Miller"
    Cc: Roland McGrath
    Cc: Kyle McMartin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ulrich Drepper
     
  • This patch adds support for flag values which are ORed to the type passwd
    to socket and socketpair. The additional code is minimal. The flag
    values in this implementation can and must match the O_* flags. This
    avoids overhead in the conversion.

    The internal functions sock_alloc_fd and sock_map_fd get a new parameters
    and all callers are changed.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #include
    #include
    #include
    #include
    #include

    #define PORT 57392

    /* For Linux these must be the same. */
    #define SOCK_CLOEXEC O_CLOEXEC

    int
    main (void)
    {
    int fd;
    fd = socket (PF_INET, SOCK_STREAM, 0);
    if (fd == -1)
    {
    puts ("socket(0) failed");
    return 1;
    }
    int coe = fcntl (fd, F_GETFD);
    if (coe == -1)
    {
    puts ("fcntl failed");
    return 1;
    }
    if (coe & FD_CLOEXEC)
    {
    puts ("socket(0) set close-on-exec flag");
    return 1;
    }
    close (fd);

    fd = socket (PF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
    if (fd == -1)
    {
    puts ("socket(SOCK_CLOEXEC) failed");
    return 1;
    }
    coe = fcntl (fd, F_GETFD);
    if (coe == -1)
    {
    puts ("fcntl failed");
    return 1;
    }
    if ((coe & FD_CLOEXEC) == 0)
    {
    puts ("socket(SOCK_CLOEXEC) does not set close-on-exec flag");
    return 1;
    }
    close (fd);

    int fds[2];
    if (socketpair (PF_UNIX, SOCK_STREAM, 0, fds) == -1)
    {
    puts ("socketpair(0) failed");
    return 1;
    }
    for (int i = 0; i < 2; ++i)
    {
    coe = fcntl (fds[i], F_GETFD);
    if (coe == -1)
    {
    puts ("fcntl failed");
    return 1;
    }
    if (coe & FD_CLOEXEC)
    {
    printf ("socketpair(0) set close-on-exec flag for fds[%d]\n", i);
    return 1;
    }
    close (fds[i]);
    }

    if (socketpair (PF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds) == -1)
    {
    puts ("socketpair(SOCK_CLOEXEC) failed");
    return 1;
    }
    for (int i = 0; i < 2; ++i)
    {
    coe = fcntl (fds[i], F_GETFD);
    if (coe == -1)
    {
    puts ("fcntl failed");
    return 1;
    }
    if ((coe & FD_CLOEXEC) == 0)
    {
    printf ("socketpair(SOCK_CLOEXEC) does not set close-on-exec flag for fds[%d]\n", i);
    return 1;
    }
    close (fds[i]);
    }

    puts ("OK");

    return 0;
    }
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Signed-off-by: Ulrich Drepper
    Acked-by: Davide Libenzi
    Cc: Michael Kerrisk
    Cc: "David S. Miller"
    Cc: Ralf Baechle
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ulrich Drepper
     
  • Signed-off-by: Akinobu Mita
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     
  • The driver is gone for a long time.

    Reported-by: Robert P. J. Day
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     
  • SOUND_TRIDENT was the last PCI OSS driver, and since there's already an
    ALSA driver for the same hardware we can remove it.

    [muli@il.ibm.com: update CREDITS]
    Signed-off-by: Adrian Bunk
    Signed-off-by: Muli Ben-Yehuda
    Signed-off-by: Muli Ben-Yehuda
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     
  • Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • When checking spacing for pointer checks the type cannot start in the
    middle of a word, ie. this is not 'int * bar':

    x = fooint * bar;

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Ensure we ignore comments in complex macro detection else we incorrectly
    report this:

    #define PFM_GROUP_PERM_ANY -1 /* any user/group */

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Now that we have a variants system, move to using that to carry the
    unary/binary designation for +, -, &, and *.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Add checks for the question mark colon operator spacing, and also check
    the other uses of colon. Colon means a number of things:

    - it introduces the else part of the ?: operator,
    - it terminates a goto label,
    - it terminates the case value,
    - it separates the identifier from the bit size on bit fields, and
    - it is used to introduce option types in asm().

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Add support for multiple modifiers such as:

    int __one __two foo;

    Also handle trailing known modifiers when defecting modifiers:

    int __one foo __read_mostly;

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Ensure we do not inadvertantly load known modifiers up as possible types.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Make sure we correctly mark the return type of the pointer to a function
    declaration.

    const void *(*sb_tag)(struct sysfs_tag_info *info);

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Exclude vmlinux.lds.h from the macro complexity checks. They will never
    apply sanely here.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Although we are finding the added modifier in the declaration below
    we are not correctly matching it as a type. Fix the declaration.

    static void __ref *vmem_alloc_pages(unsigned int order)
    {
    }

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Improve type matcher debug so we can see what it does match. As part
    of this move us to to using the common debug framework.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Allow for type modifiers mid declaration on multiple declarations:

    struct mxser_mstatus ms, __user *msu = argp;

    Reported by Jiri Slaby.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Correct spelling in the kfree reports.

    Signed-off-by: Wolfram Sang
    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wolfram Sang
     
  • usb_free_urb() can take a NULL, so let's check and warn about that.

    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Greg Kroah-Hartman
     
  • Check to see if the block/statement which a condition or loop introduces
    is indented correctly.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Extend the trailing statement checks to report a trailing semi-colon ';'
    as we really want it on the next line and indented so it is really really
    obvious. Also extend the tests to include while and for.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Check on the spacing before square brackets. We should only allow spaces
    there if this is part of a type definition or an initialialiser.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Report trailing statements on case and default lines.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Allow printk strings to break the 80 character width limits, thus keeping
    them complete and searchable.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Fix end of statement location. Where the last line of the statement is
    replaced we are miss reporting the newly added replacement an incorrectly
    indented trailing statement for the negative context. We are also
    incorrectly reporting negative statements generally.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • We are incorrectly counting the lines in a block while accumulating
    the trailing lines in a macro statement, leading to false positives.
    Fix end of block handling and general counting for negative context lines.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • When we see a goto we enter unary context. For example:

    goto *h;

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • When looking for an associated comment they may be suffixed by a macro
    continuation. Ignore this.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • We are false matching __asm__ as a type, and then tripping the external
    function checks. Squash.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • [apw@shadowen.org: generalise pattern and add tests]
    Signed-off-by: Michael Ellerman
    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Ellerman
     
  • Some types such as typedefs may overlap real identifiers. Be more
    targetted about when a type can really exist. Where it cannot let it be
    an identifier. This prevents false reporting of the minus '-' in unary
    context in the following:

    foo[bar->bool - 1];

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Casts require parentheses so it is possible to have something like this:

    return (int)(*a);

    This miss trips the complexity function. Ensure that the two separate
    parenthesised sections are not coelesced.

    Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • Signed-off-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Whitcroft
     
  • This patch will only setup one clock, if free, and return this clock to the
    caller. The previous solution would setup both clocks with the same prescaler
    and divider and return PWM_CPR_CLKB, thus taking both clocks in the same call
    without the caller knowing.

    Signed-off-by: Hans-Christian Egtvedt
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hans-Christian Egtvedt
     
  • set_type returns an int indicating success or failure, but up to now
    setup_irq ignores that.

    In my case this resulted in a machine hang:

    gpio-keys requested IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, but
    arm/ns9xxx can only trigger on one direction so set_type didn't touch
    the configuration which happens do default to a level sensitiveness and
    returned -EINVAL. setup_irq ignored that and unmasked the irq. This
    resulted in an endless triggering of the gpio-key interrupt service
    routine which effectively killed the machine.

    With this patch applied setup_irq propagates the error to the caller.

    Note that before in the case

    chip && !chip->set_type && !chip->name

    a NULL pointer was feed to printk. This is fixed, too.

    Signed-off-by: Uwe Kleine-König
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Uwe Kleine-König
     
  • Trying to compile the v850 port brings many compile errors, one of them exists
    since at least kernel 2.6.19.

    There also seems to be noone willing to bring this port back into a usable
    state.

    This patch therefore removes the v850 port.

    If anyone ever decides to revive the v850 port the code will still be
    available from older kernels, and it wouldn't be impossible for the port to
    reenter the kernel if it would become actively maintained again.

    Signed-off-by: Adrian Bunk
    Acked-by: Greg Ungerer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     
  • - Make some variables and functions static, since they don't need to be
    global.

    - Remove an unused function - arch/um/kernel/time.c::sched_clock().

    - Clean the style a bit as complained by checkpatch.pl.

    Cc: Jeff Dike
    Signed-off-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    WANG Cong
     
  • - Remove arch_validate(), because no one uses it.

    - Remove useless macro HAVE_ARCH_VALIDATE.

    - Make the variable 'empty_bad_page' static.

    Cc: Jeff Dike
    Signed-off-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    WANG Cong
     
  • Make activate_fd() and free_irq_by_irq_and_dev() static. Remove
    init_aio_irq() since it has no users.

    Cc: Jeff Dike
    Signed-off-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    WANG Cong
     
  • Signed-off-by: Akinobu Mita
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita