diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-11-27 02:10:51 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-11-27 02:10:51 +0100 |
commit | 6eb1fd3ee280a87d8074adabf6694a0aeeaf456b (patch) | |
tree | c2d4a4c289af6bc3bf37ff4ef664df1494cd9e71 | |
parent | 3db7d9bd54c84ac36b83d7061228866b4634b22c (diff) |
Usafe of sizeof
-rw-r--r-- | FICS/makerank.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/FICS/makerank.c b/FICS/makerank.c index d590818..ca3b65a 100644 --- a/FICS/makerank.c +++ b/FICS/makerank.c @@ -38,18 +38,18 @@ GetPlayerInfo(char *fileName, ENTRY *e) } if ((fp = fopen(fileName, "r")) == NULL || - fgets(line, sizeof line - 1, fp) == NULL || + fgets(line, sizeof line, fp) == NULL || feof(fp)) return 0; if (!strcmp(line, "v 1\n")) { - fgets(line, 99, fp); + fgets(line, sizeof line, fp); sscanf(line, "%s", e->name); - fgets(line, 99, fp); - fgets(line, 99, fp); - fgets(line, 99, fp); + fgets(line, sizeof line, fp); + fgets(line, sizeof line, fp); + fgets(line, sizeof line, fp); if (fscanf(fp, "%d %*u %*u %*u %d %*u %*u %*u %*u %d %*u %*u " "%*u %d %*u %*u %*u %*u %d %*u %*u %*u %d %*u %*u %*u %*u " @@ -101,7 +101,7 @@ GetPlayerInfo(char *fileName, ENTRY *e) done = 1; } - fgets(line, 99, fp); + fgets(line, sizeof line, fp); } while (!done && !feof(fp)); } @@ -137,7 +137,7 @@ LoadEntries(void) continue; while (1) { - fgets(e.name, MAX_LOGIN_NAME, fpPlayerList); + fgets(e.name, sizeof(e.name), fpPlayerList); if (feof(fpPlayerList)) break; @@ -194,7 +194,7 @@ SetComputers(int n) return 0; while (i < n) { - fgets(comp, 29, fpComp); + fgets(comp, sizeof comp, fpComp); if (feof(fpComp)) break; |