diff --git a/include/ntfs-3g/logging.h b/include/ntfs-3g/logging.h index bc84734f..ae36210a 100644 --- a/include/ntfs-3g/logging.h +++ b/include/ntfs-3g/logging.h @@ -37,7 +37,8 @@ typedef int (ntfs_log_handler)(const char *function, const char *file, int line, u32 level, void *data, const char *format, va_list args); /* Set the logging handler from one of the functions, below. */ -void ntfs_log_set_handler(ntfs_log_handler *handler); +void ntfs_log_set_handler(ntfs_log_handler *handler + __attribute__((format(printf, 6, 0)))); /* Logging handlers */ ntfs_log_handler ntfs_log_handler_syslog __attribute__((format(printf, 6, 0))); diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 46a8bde2..d7b574f6 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -1285,10 +1285,10 @@ retry: "%lld.\n", to_write, rl->vcn, rl->lcn, ofs); if (!NVolReadOnly(vol)) { - s64 pos = (rl->lcn << vol->cluster_size_bits) + ofs; - u32 bsize = vol->cluster_size; + s64 wpos = (rl->lcn << vol->cluster_size_bits) + ofs; s64 wend = (rl->vcn << vol->cluster_size_bits) + ofs + to_write; - s64 rounded = ((wend + bsize - 1) & ~(s64)(bsize - 1)) - wend; + u32 bsize = vol->cluster_size; + s64 rounded = ((wend + bsize - 1) & ~(s64)(bsize - 1)) - wend; /* * Zero fill to cluster boundary if we're writing to an @@ -1312,13 +1312,13 @@ retry: memcpy(cb, b, to_write); memset(cb + to_write, 0, rounded - to_write); - written = ntfs_pwrite(vol->dev, pos, rounded, cb); + written = ntfs_pwrite(vol->dev, wpos, rounded, cb); if (written == rounded) written = to_write; free(cb); } else - written = ntfs_pwrite(vol->dev, pos, to_write, b); + written = ntfs_pwrite(vol->dev, wpos, to_write, b); } else written = to_write; /* If everything ok, update progress counters and continue. */ diff --git a/libntfs-3g/logging.c b/libntfs-3g/logging.c index 90a20cf1..7d3fe735 100644 --- a/libntfs-3g/logging.c +++ b/libntfs-3g/logging.c @@ -67,7 +67,7 @@ static const char *col_end = "\e[0m"; struct ntfs_logging { u32 levels; u32 flags; - ntfs_log_handler *handler; + ntfs_log_handler *handler __attribute__((format(printf, 6, 0))); }; /** @@ -355,14 +355,14 @@ int ntfs_log_handler_syslog(const char *function __attribute__((unused)), void *data __attribute__((unused)), const char *format, va_list args) { - char log[LOG_LINE_LEN]; + char logbuf[LOG_LINE_LEN]; int ret, olderr = errno; #ifndef DEBUG if ((level & NTFS_LOG_LEVEL_PERROR) && errno == ENOSPC) return 1; #endif - ret = vsnprintf(log, LOG_LINE_LEN, format, args); + ret = vsnprintf(logbuf, LOG_LINE_LEN, format, args); if (ret < 0) { vsyslog(LOG_NOTICE, format, args); ret = 1; @@ -370,12 +370,12 @@ int ntfs_log_handler_syslog(const char *function __attribute__((unused)), } if ((LOG_LINE_LEN > ret + 3) && (level & NTFS_LOG_LEVEL_PERROR)) { - strncat(log, ": ", LOG_LINE_LEN - ret - 1); - strncat(log, strerror(olderr), LOG_LINE_LEN - (ret + 3)); - ret = strlen(log); + strncat(logbuf, ": ", LOG_LINE_LEN - ret - 1); + strncat(logbuf, strerror(olderr), LOG_LINE_LEN - (ret + 3)); + ret = strlen(logbuf); } - syslog(LOG_NOTICE, "%s", log); + syslog(LOG_NOTICE, "%s", logbuf); out: errno = olderr; return ret; diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index 2729ae08..489edc65 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -357,7 +357,7 @@ int ntfs_sd_add_everyone(ntfs_inode *ni) */ le32 ntfs_security_hash(const SECURITY_DESCRIPTOR_RELATIVE *sd, const u32 len) { - const le32 *pos = (le32 *)sd; + const le32 *pos = (const le32 *)sd; const le32 *end = pos + (len >> 2); u32 hash = 0; diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index ab63eb31..a308009e 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -568,10 +568,8 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx, if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user || ctx->show_sys_files) { - struct stat st = {}; + struct stat st = { .st_ino = MREF(mref) }; - st.st_ino = MREF(mref); - if (dt_type == NTFS_DT_REG) st.st_mode = S_IFREG | (0777 & ~ctx->fmask); else if (dt_type == NTFS_DT_DIR) @@ -1670,7 +1668,7 @@ static ntfs_volume *ntfs_open(const char *device, char *mntpoint, int blkdev) if (ctx->force) flags |= MS_FORCE; - ctx->vol = utils_mount_volume(device, mntpoint, flags, ctx->force); + ctx->vol = utils_mount_volume(device, mntpoint, flags); return ctx->vol; } diff --git a/src/utils.c b/src/utils.c index d066a0d1..2b14f74d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -110,7 +110,7 @@ int utils_set_locale(void) } ntfs_volume *utils_mount_volume(const char *volume, const char *mntpoint, - unsigned long flags, BOOL force) + unsigned long flags) { ntfs_volume *vol; diff --git a/src/utils.h b/src/utils.h index eccc9a95..400d465f 100644 --- a/src/utils.h +++ b/src/utils.h @@ -34,6 +34,6 @@ extern const char *ntfs_gpl; int utils_set_locale(void); ntfs_volume *utils_mount_volume(const char *device, const char *mntpoint, - unsigned long flags, BOOL force); + unsigned long flags); #endif /* _NTFS_UTILS_H_ */