lkml.org 
[lkml]   [2002]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] 2.5.17 /dev/ports
Hi Martin.

> #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;
> }
> }

Interesting code. Did you really mean to have the program name as the
port number, or should that be argv[1] and argv[2] instead? Also, what
is it supposed to do? A quick analysis makes no sense of it.

Would the following be what you had intended?

#include <linux/io.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
int byte, port, result = 0;

switch (argc) {
case 2:
port = atoi(argv[1]);
result = inb(port);
break;

case 3:
port = atoi(argv[1]);
byte = atoi(argv[2]);
outb(port, byte);
break;

default:
fprintf(stderr, "Usage: %s port [byte]\n", argv[0]);
break;
}
return result;
}

Best wishes from Riley.

-
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:0.114 / U:1.664 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site