Parcourir la source

Remove debugging lines, change scanf format

Check if scanf format was invalid
Mateusz Bugdalski il y a 13 ans
Parent
commit
807695179c
1 fichiers modifiés avec 3 ajouts et 7 suppressions
  1. 3 7
      lpc.c

+ 3 - 7
lpc.c

@@ -89,7 +89,7 @@ int lpc_command(char *text, ...) {
   vprintf(text, l);
   fflush(stdout);
   fgets(buf, sizeof(buf), stdin); /* deny echoed line */
-  if(scanf("%d\r\n", &res)<1)
+  if(scanf("%d", &res)<1)
     return -1;
   va_end(l);
   return res;
@@ -98,15 +98,11 @@ int lpc_command(char *text, ...) {
 int lpc_read_partid(struct lpc_device *dev) {
   int i;
   int res;
-  int partid;
+  unsigned int partid;
   res = lpc_command("J\r\n");
-  sprog_error("Command return code is %d\n", res);
   if(res!=0)
     return res;
-  if(scanf("%d\r\n", &partid)<1)
-    sprog_error("Unable to read part ID\n");
-  else 
-    sprog_error("Received part ID: %d (0x%08x)\n", partid, partid);
+  scanf("%u", &partid);
   for(i=0; lpc_parts[i].name; i++)
     if(lpc_parts[i].part_id==partid)
       break;