]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
scsi_serial: convert from nanosleep() to usleep_safe() 29239/head
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Sep 2023 09:18:59 +0000 (11:18 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Sep 2023 10:07:28 +0000 (12:07 +0200)
src/udev/scsi_id/scsi_serial.c

index a271b1786cfa3011d7309e7a3fada09df4f56730..aed6082620e33139a64a76cf14030a23ee42d35c 100644 (file)
@@ -793,14 +793,11 @@ int scsi_get_serial(struct scsi_id_device *dev_scsi, const char *devname,
 
         memzero(dev_scsi->serial, len);
         for (cnt = 20; cnt > 0; cnt--) {
-                struct timespec duration;
-
                 fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY);
                 if (fd >= 0 || errno != EBUSY)
                         break;
-                duration.tv_sec = 0;
-                duration.tv_nsec = (200 * 1000 * 1000) + (random_u32() % 100 * 1000 * 1000);
-                nanosleep(&duration, NULL);
+
+                usleep_safe(200U*USEC_PER_MSEC + random_u64_range(100U*USEC_PER_MSEC));
         }
         if (fd < 0)
                 return 1;