commit - 3b2fd45fff2691d0088fadc8239a062ad2f02c84
commit + 9ddfc63fb8efeb84c9a9ff16396b689c1565b4a6
blob - 9410429ecd5285a48591106395019d98ed234451
blob + 0ac1d9c8e1c8e858939ace03b287942d2cb198a0
--- FICS/ratings.c
+++ FICS/ratings.c
{
FILE *fp;
char fname[MAX_FILENAME_SIZE] = { '\0' };
+ int fd;
snprintf(fname, sizeof fname, "%s/newratingsV%d_data", stats_dir,
STATS_VERSION);
- if ((fp = fopen(fname, "w")) == NULL) {
+ errno = 0;
+ fd = open(fname, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+
+ if (fd < 0) {
warn("%s: can't write ratings data", __func__);
return;
+ } else if ((fp = fdopen(fd, "w")) == NULL) {
+ warn("%s: can't write ratings data", __func__);
+ close(fd);
+ return;
}
fprintf(fp, "%10f %10f %10f %d\n", Rb_M, Rb_S, Rb_total, Rb_count);