lkml.org 
[lkml]   [2002]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] 2.5.17 /dev/ports
On Wed, May 22, 2002 at 06:17:26PM +0200, Martin Dalecki wrote:
> #include <linux/io.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(char *argv[], int argc)
> {
> int port = aoit(argv[0]);
> int byte = aoit(argv[1]);
>
> if (port > 0)
> return inb(port);
> else
> outb(port, byte);
>
>
> return 0;
> }

Erm:

1. not checking number of arguments passed.
2. thinking argv[0] is the first arg.
3. wrong test for in/out (port > 0 -> inb, port <= 0 -> outb)
4. returning the read byte via the program status code.
5. aoit is an undefined function.
6. including linux/*.h is fundamentally wrong for any user space
program.

That's one bug every 2 lines. Should I continue? 8)

--
Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

-
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 13:26    [W:1.045 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site