[arch-commits] Commit in udev/trunk (resolve-modalias.c)
Aaron Griffin
aaron at archlinux.org
Wed Jan 21 05:31:22 UTC 2009
Date: Wednesday, January 21, 2009 @ 00:31:22
Author: aaron
Revision: 24803
Add some error handling to resolve-modalias.c
Modified:
udev/trunk/resolve-modalias.c
--------------------+
resolve-modalias.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
Modified: resolve-modalias.c
===================================================================
--- resolve-modalias.c 2009-01-21 02:48:22 UTC (rev 24802)
+++ resolve-modalias.c 2009-01-21 05:31:22 UTC (rev 24803)
@@ -42,10 +42,20 @@
}
int main(int argc, char *argv[]) {
- FILE *f=fopen(argv[1], "r");
char *line, *pattern, *module;
char *pos1, *pos2;
+ if(argc != 3) {
+ fprintf(stderr, "usage: resolve-modalias <alias file> <modalias>\n");
+ return 1;
+ }
+
+ FILE *f=fopen(argv[1], "r");
+ if(!f) {
+ perror("error opening alias file");
+ return 1;
+ }
+
while((line=getline(f))!=NULL) {
if(!strncmp(line, "alias", strlen("alias"))) {
pos1 = index(line, ' ');
@@ -60,3 +70,4 @@
}
return 0;
}
+//vim: set ts=2 sw=2 et:
More information about the arch-commits
mailing list