Rewrite loop to do what it shall do.
authordrepper <drepper>
Mon, 4 Aug 1997 14:30:19 +0000 (14:30 +0000)
committerdrepper <drepper>
Mon, 4 Aug 1997 14:30:19 +0000 (14:30 +0000)
termios/cfsetspeed.c

index da31073..b3c8aa3 100644 (file)
@@ -107,13 +107,19 @@ cfsetspeed (struct termios *termios_p, speed_t speed)
 {
   size_t cnt;
 
-  for (cnt = 0; cnt < sizeof (speeds); ++cnt)
-    if (speed == speeds[cnt].value)
+  for (cnt = 0; cnt < sizeof (speeds) / sizeof (speeds[0]); ++cnt)
+    if (speed == speeds[cnt].internal)
       {
        cfsetispeed (termios_p, speed);
        cfsetospeed (termios_p, speed);
        return;
       }
+    else if (speed == speeds[cnt].value)
+      {
+       cfsetispeed (termios_p, speeds[cnt].internal);
+       cfsetospeed (termios_p, speeds[cnt].internal);
+       return;
+      }
 
   __set_errno (EINVAL);
 }