diff options
| author | Paul Eggert | 2023-03-21 14:38:23 -0700 |
|---|---|---|
| committer | Paul Eggert | 2023-03-21 14:42:18 -0700 |
| commit | 640fd9b594fa376e6493efbe0cf083e1270ddd3f (patch) | |
| tree | 2659bb3c0bc63db9d7bbd7491e9241a691384f6a /lib-src | |
| parent | 2e8cc206f520ec9feb42273703d7afbcb32cd791 (diff) | |
| download | emacs-640fd9b594fa376e6493efbe0cf083e1270ddd3f.tar.gz emacs-640fd9b594fa376e6493efbe0cf083e1270ddd3f.zip | |
Sleep less in update-game-score
This is mostly to avoid interface hassles with time/srand/rand.
* lib-src/update-game-score.c (main): Don’t use ‘srand’ or ‘time’.
(lock_file): Don’t sleep if we unlocked the lock file. When
sleeping, always just sleep 1 s. This avoids the need for calling
‘time’ and ‘rand’, the utility of which was dubious anyway.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/update-game-score.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index 83167f59b8a..4592e14d1d6 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c | |||
| @@ -185,8 +185,6 @@ main (int argc, char **argv) | |||
| 185 | ptrdiff_t scorecount, scorealloc; | 185 | ptrdiff_t scorecount, scorealloc; |
| 186 | ptrdiff_t max_scores = MAX_SCORES; | 186 | ptrdiff_t max_scores = MAX_SCORES; |
| 187 | 187 | ||
| 188 | srand (time (0)); | ||
| 189 | |||
| 190 | while ((c = getopt (argc, argv, "hrm:d:")) != -1) | 188 | while ((c = getopt (argc, argv, "hrm:d:")) != -1) |
| 191 | switch (c) | 189 | switch (c) |
| 192 | { | 190 | { |
| @@ -485,8 +483,8 @@ lock_file (const char *filename, void **state) | |||
| 485 | return -1; | 483 | return -1; |
| 486 | attempts = 0; | 484 | attempts = 0; |
| 487 | } | 485 | } |
| 488 | 486 | else | |
| 489 | sleep ((rand () & 1) + 1); | 487 | sleep (1); |
| 490 | } | 488 | } |
| 491 | 489 | ||
| 492 | close (fd); | 490 | close (fd); |