diff options
author | Richard M. Stallman <rms@gnu.org> | 2003-02-04 12:03:44 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2003-02-04 12:03:44 +0000 |
commit | 1de3eaca77bade9494294a4514901ae3d2ea9129 (patch) | |
tree | 5c0c64dd87c2a8c3f0df465232f8b049970d1a9d /lib-src | |
parent | 27963c17e1d89d0e1f647f0e79a690246bd57c9e (diff) | |
download | emacs-1de3eaca77bade9494294a4514901ae3d2ea9129.tar.gz |
(push_score, read_scores): Cast values of malloc and realloc.
(main, lock_file): Avoid assignment inside if.
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/update-game-score.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index 2e526b00bd0..d871e336802 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c @@ -213,7 +213,8 @@ main (argc, argv) if (strlen (newdata) > MAX_DATA_LEN) newdata[MAX_DATA_LEN] = '\0'; - if ((user_id = get_user_id ()) == NULL) + user_id = get_user_id (); + if (user_id == NULL) lose_syserr ("Couldn't determine user id"); if (stat (scorefile, &buf) < 0) @@ -345,7 +346,7 @@ read_scores (filename, scores, count) return -1; scorecount = 0; cursize = 16; - ret = malloc (sizeof (struct score_entry) * cursize); + ret = (struct score_entry *) malloc (sizeof (struct score_entry) * cursize); if (!ret) return -1; while ((readval = read_score (f, &ret[scorecount])) == 0) @@ -356,7 +357,7 @@ read_scores (filename, scores, count) scorecount++; if (scorecount >= cursize) { - ret = realloc (ret, cursize *= 2); + ret = (struct score_entry *) realloc (ret, cursize *= 2); if (!ret) return -1; } @@ -394,8 +395,8 @@ push_score (scores, count, newscore, username, newdata) char *newdata; { struct score_entry *newscores - = realloc (*scores, - sizeof (struct score_entry) * ((*count) + 1)); + = (struct score_entry *) realloc (*scores, + sizeof (struct score_entry) * ((*count) + 1)); if (!newscores) return -1; newscores[*count].score = newscore; @@ -469,7 +470,8 @@ lock_file (filename, state) if (stat (lockpath, &buf) == 0 && (difftime (buf.st_ctime, time (NULL) > 60*60))) unlink (lockpath); - if ((fd = open (lockpath, O_CREAT | O_EXCL, 0600)) < 0) + fd = open (lockpath, O_CREAT | O_EXCL, 0600); + if (fd < 0) { if (errno == EEXIST) { |