Browse Source

Merge commit '6f45c8b' into erupter

Luke Dashjr 12 years ago
parent
commit
32c2714b44
1 changed files with 6 additions and 1 deletions
  1. 6 1
      fpgautils.c

+ 6 - 1
fpgautils.c

@@ -197,6 +197,7 @@ int _serial_autodetect_sysfs(detectone_func_t detectone, va_list needles)
 	char devpath[sizeof(devroot) + (NAME_MAX * 3)];
 	char buf[0x100];
 	char *devfile, *upfile;
+	char *rs;
 	char found = 0;
 	size_t len, len2;
 	
@@ -213,7 +214,11 @@ int _serial_autodetect_sysfs(detectone_func_t detectone, va_list needles)
 		devfile = upfile + len;
 		strcpy(devfile, "/product");
 		F = fopen(devpath, "r");
-		if (!(F && fgets(buf, sizeof(buf), F)))
+		if (!F)
+			continue;
+		rs = fgets(buf, sizeof(buf), F);
+		fclose(F);
+		if (!rs)
 			continue;
 		
 		if (!SEARCH_NEEDLES(buf))