X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=nss%2Ffile.c;h=6da0fd656663a6402db230d0f57a11b4abeb88d8;hp=30ea4f9b5f96910f0cd0ba8d353cfa7dbccea076;hb=0d99032f2a22b97cd7c49bfba4a6cd0b41fd87d6;hpb=98f2fc8312dc5611bd85229f0b6faa0a4356ea66 diff --git a/nss/file.c b/nss/file.c index 30ea4f9..6da0fd6 100644 --- a/nss/file.c +++ b/nss/file.c @@ -31,10 +31,7 @@ bool map_file(const char *path, struct file *f) { // Fully initialize the struct for unmap_file() and other users - f->fd = -1; - f->size = 0; - f->next_index = 0; - f->header = NULL; + memset(f, 0, sizeof(*f)); f->fd = open(path, O_RDONLY | O_CLOEXEC); if (f->fd < 0) { @@ -81,7 +78,7 @@ void unmap_file(struct file *f) { munmap((void *)f->header, f->size); f->header = NULL; } - if (f->fd != -1) { + if (f->fd >= 0) { close(f->fd); f->fd = -1; }