aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2003-02-04 12:03:44 +0000
committerRichard M. Stallman2003-02-04 12:03:44 +0000
commit00a7e40898fb14a6c9b1e7511143fc4447fefe58 (patch)
tree2b091dbe9358a4f702ab746345716fb2ad1a56fb
parenta5d107f3c71c8d38d150cc2626440c8f9c52e9be (diff)
downloademacs-00a7e40898fb14a6c9b1e7511143fc4447fefe58.tar.gz
emacs-00a7e40898fb14a6c9b1e7511143fc4447fefe58.zip
(push_score, read_scores): Cast values of malloc and realloc.
(main, lock_file): Avoid assignment inside if.
-rw-r--r--lib-src/update-game-score.c14
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)
213 if (strlen (newdata) > MAX_DATA_LEN) 213 if (strlen (newdata) > MAX_DATA_LEN)
214 newdata[MAX_DATA_LEN] = '\0'; 214 newdata[MAX_DATA_LEN] = '\0';
215 215
216 if ((user_id = get_user_id ()) == NULL) 216 user_id = get_user_id ();
217 if (user_id == NULL)
217 lose_syserr ("Couldn't determine user id"); 218 lose_syserr ("Couldn't determine user id");
218 219
219 if (stat (scorefile, &buf) < 0) 220 if (stat (scorefile, &buf) < 0)
@@ -345,7 +346,7 @@ read_scores (filename, scores, count)
345 return -1; 346 return -1;
346 scorecount = 0; 347 scorecount = 0;
347 cursize = 16; 348 cursize = 16;
348 ret = malloc (sizeof (struct score_entry) * cursize); 349 ret = (struct score_entry *) malloc (sizeof (struct score_entry) * cursize);
349 if (!ret) 350 if (!ret)
350 return -1; 351 return -1;
351 while ((readval = read_score (f, &ret[scorecount])) == 0) 352 while ((readval = read_score (f, &ret[scorecount])) == 0)
@@ -356,7 +357,7 @@ read_scores (filename, scores, count)
356 scorecount++; 357 scorecount++;
357 if (scorecount >= cursize) 358 if (scorecount >= cursize)
358 { 359 {
359 ret = realloc (ret, cursize *= 2); 360 ret = (struct score_entry *) realloc (ret, cursize *= 2);
360 if (!ret) 361 if (!ret)
361 return -1; 362 return -1;
362 } 363 }
@@ -394,8 +395,8 @@ push_score (scores, count, newscore, username, newdata)
394 char *newdata; 395 char *newdata;
395{ 396{
396 struct score_entry *newscores 397 struct score_entry *newscores
397 = realloc (*scores, 398 = (struct score_entry *) realloc (*scores,
398 sizeof (struct score_entry) * ((*count) + 1)); 399 sizeof (struct score_entry) * ((*count) + 1));
399 if (!newscores) 400 if (!newscores)
400 return -1; 401 return -1;
401 newscores[*count].score = newscore; 402 newscores[*count].score = newscore;
@@ -469,7 +470,8 @@ lock_file (filename, state)
469 if (stat (lockpath, &buf) == 0 470 if (stat (lockpath, &buf) == 0
470 && (difftime (buf.st_ctime, time (NULL) > 60*60))) 471 && (difftime (buf.st_ctime, time (NULL) > 60*60)))
471 unlink (lockpath); 472 unlink (lockpath);
472 if ((fd = open (lockpath, O_CREAT | O_EXCL, 0600)) < 0) 473 fd = open (lockpath, O_CREAT | O_EXCL, 0600);
474 if (fd < 0)
473 { 475 {
474 if (errno == EEXIST) 476 if (errno == EEXIST)
475 { 477 {