From 3244f17522b28ff28500bf688e7a74ebd173849b Mon Sep 17 00:00:00 2001 From: "cantab.net!aia21" Date: Wed, 7 Jan 2004 15:03:17 +0000 Subject: [PATCH] Enable lots of compiler warnings and fix warning from libntfs. (Logical change 1.257) --- configure | 4 ++-- configure.ac | 4 ++-- include/attrib.h | 2 ++ include/bootsect.h | 3 +-- include/debug.h | 8 ++++---- include/device.h | 2 +- include/mft.h | 2 +- include/volume.h | 2 ++ libntfs/attrib.c | 4 ++-- libntfs/bootsect.c | 2 +- libntfs/device.c | 4 ++-- libntfs/inode.c | 2 ++ libntfs/lcnalloc.c | 2 +- libntfs/mft.c | 6 +++--- libntfs/runlist.c | 10 +++++----- libntfs/volume.c | 6 ++++-- ntfsprogs/utils.c | 14 +++++++------- ntfsprogs/utils.h | 4 ++-- 18 files changed, 44 insertions(+), 37 deletions(-) diff --git a/configure b/configure index 44503d3a..59ef7e76 100755 --- a/configure +++ b/configure @@ -8249,9 +8249,9 @@ echo "${ECHO_T}$cc_version" >&6 # enable 64-bit (device) file access functions and parameters. CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -Wall" -# Add extra warnings if in maintainer mode. +# Add lots of extra warnings if in maintainer mode. if test "$USE_MAINTAINER_MODE" = "yes";then - CFLAGS="$CFLAGS -Wstrict-prototypes -Wsign-compare" + CFLAGS="$CFLAGS -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wwrite-strings -W -Wcast-align -Waggregate-return -Wbad-function-cast -Wcast-qual -Wundef -Wredundant-decls -Wsign-compare" fi # Add -fms-extensions for gcc-3.2+. diff --git a/configure.ac b/configure.ac index 09acf0c5..0f5d0830 100644 --- a/configure.ac +++ b/configure.ac @@ -136,9 +136,9 @@ AC_MSG_RESULT($cc_version) # enable 64-bit (device) file access functions and parameters. CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -Wall" -# Add extra warnings if in maintainer mode. +# Add lots of extra warnings if in maintainer mode. if test "$USE_MAINTAINER_MODE" = "yes";then - CFLAGS="$CFLAGS -Wstrict-prototypes -Wsign-compare" + CFLAGS="$CFLAGS -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wwrite-strings -W -Wcast-align -Waggregate-return -Wbad-function-cast -Wcast-qual -Wundef -Wredundant-decls -Wsign-compare" fi # Add -fms-extensions for gcc-3.2+. diff --git a/include/attrib.h b/include/attrib.h index 9ed5d54d..f8610261 100644 --- a/include/attrib.h +++ b/include/attrib.h @@ -262,6 +262,8 @@ extern int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPES type, const s64 size); extern int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPES type); +extern int ntfs_attr_can_be_resident(const ntfs_volume *vol, + const ATTR_TYPES type); extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, const u32 newsize); diff --git a/include/bootsect.h b/include/bootsect.h index d2ad2e57..345f48d9 100644 --- a/include/bootsect.h +++ b/include/bootsect.h @@ -39,8 +39,7 @@ * disregarding the value of silent (but only if configure was run with * --enable-debug). */ -extern BOOL ntfs_boot_sector_is_ntfs(const NTFS_BOOT_SECTOR *b, - const BOOL silent); +extern BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b, BOOL silent); extern int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b); #endif /* defined _NTFS_BOOTSECT_H */ diff --git a/include/debug.h b/include/debug.h index 440d2112..df6b6886 100644 --- a/include/debug.h +++ b/include/debug.h @@ -68,10 +68,10 @@ extern void ntfs_debug_runlist_dump(const runlist_element *rl); #else /* if !DEBUG */ -static __inline__ void Dprintf(const char *fmt, ...) {} -static __inline__ void Dputs(const char *s) {} -static __inline__ void Dperror(const char *s) {} -static __inline__ void ntfs_debug_runlist_dump(const runlist_element *rl) {} +static __inline__ void Dprintf(const char *fmt __attribute__((unused)), ...) {} +static __inline__ void Dputs(const char *s __attribute__((unused))) {} +static __inline__ void Dperror(const char *s __attribute__((unused))) {} +static __inline__ void ntfs_debug_runlist_dump(const runlist_element *rl __attribute__((unused))) {} #endif /* !DEBUG */ diff --git a/include/device.h b/include/device.h index 928ef3f8..615352a8 100644 --- a/include/device.h +++ b/include/device.h @@ -96,7 +96,7 @@ extern s64 ntfs_pwrite(struct ntfs_device *dev, const s64 pos, s64 count, extern s64 ntfs_mst_pread(struct ntfs_device *dev, const s64 pos, s64 count, const u32 bksize, void *b); extern s64 ntfs_mst_pwrite(struct ntfs_device *dev, const s64 pos, s64 count, - const u32 bksize, const void *b); + const u32 bksize, void *b); extern s64 ntfs_cluster_read(const ntfs_volume *vol, const s64 lcn, const s64 count, void *b); diff --git a/include/mft.h b/include/mft.h index ff423fe7..d45ae7a8 100644 --- a/include/mft.h +++ b/include/mft.h @@ -101,7 +101,7 @@ static __inline__ u32 ntfs_mft_record_get_data_size(const MFT_RECORD *m) return le32_to_cpu(m->bytes_in_use); } -extern ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, u64 start); +extern ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, s64 start); extern int ntfs_mft_record_free(ntfs_volume *vol, ntfs_inode *ni); diff --git a/include/volume.h b/include/volume.h index 4d8c042b..911a6e52 100644 --- a/include/volume.h +++ b/include/volume.h @@ -174,6 +174,8 @@ extern ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, extern ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long rwflag); +extern int ntfs_device_umount(ntfs_volume *vol, const BOOL force); + extern ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag); extern int ntfs_umount(ntfs_volume *vol, const BOOL force); diff --git a/libntfs/attrib.c b/libntfs/attrib.c index 86555c73..4f205329 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -64,7 +64,7 @@ s64 ntfs_get_attribute_value_length(const ATTR_RECORD *a) * ntfs_get_attribute_value */ s64 ntfs_get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m, - const ATTR_RECORD *a, u8 *b) + const ATTR_RECORD *a, u8 *b) { runlist *rl; s64 total, r; @@ -91,7 +91,7 @@ s64 ntfs_get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m, return 0; } - memcpy(b, (char*)a + le16_to_cpu(a->value_offset), + memcpy(b, (const char*)a + le16_to_cpu(a->value_offset), le32_to_cpu(a->value_length)); errno = 0; return (s64)le32_to_cpu(a->value_length); diff --git a/libntfs/bootsect.c b/libntfs/bootsect.c index c386e464..df12276c 100644 --- a/libntfs/bootsect.c +++ b/libntfs/bootsect.c @@ -43,7 +43,7 @@ * * Return TRUE if @b contains a valid ntfs boot sector and FALSE if not. */ -BOOL ntfs_boot_sector_is_ntfs(const NTFS_BOOT_SECTOR *b, const BOOL silent) +BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b, const BOOL silent) { u32 i; diff --git a/libntfs/device.c b/libntfs/device.c index 39414392..d6a3592d 100644 --- a/libntfs/device.c +++ b/libntfs/device.c @@ -213,7 +213,7 @@ s64 ntfs_pwrite(struct ntfs_device *dev, const s64 pos, s64 count, NDevSetDirty(dev); /* Write the data. */ for (total = 0; count; count -= written, total += written) { - written = dops->write(dev, (char*)b + total, count); + written = dops->write(dev, (const char*)b + total, count); /* If everything ok, continue. */ if (written > 0) continue; @@ -316,7 +316,7 @@ s64 ntfs_mst_pread(struct ntfs_device *dev, const s64 pos, s64 count, * achieved. */ s64 ntfs_mst_pwrite(struct ntfs_device *dev, const s64 pos, s64 count, - const u32 bksize, const void *b) + const u32 bksize, void *b) { s64 written, i; diff --git a/libntfs/inode.c b/libntfs/inode.c index 81e08fbd..772ccc96 100644 --- a/libntfs/inode.c +++ b/libntfs/inode.c @@ -47,6 +47,8 @@ static __inline__ ntfs_inode *__ntfs_inode_allocate(ntfs_volume *vol) return ni; } +extern ntfs_inode *ntfs_inode_allocate(ntfs_volume *vol); + /** * Internal: * diff --git a/libntfs/lcnalloc.c b/libntfs/lcnalloc.c index f960cc14..a8e53b41 100644 --- a/libntfs/lcnalloc.c +++ b/libntfs/lcnalloc.c @@ -106,7 +106,7 @@ runlist *ntfs_cluster_alloc(ntfs_volume *vol, s64 count, LCN start_lcn, (long long)start_lcn, zone == MFT_ZONE ? "MFT" : "DATA"); if (!vol || count < 0 || start_lcn < -1 || !vol->lcnbmp_na || - zone < FIRST_ZONE || zone > LAST_ZONE) { + (s8)zone < FIRST_ZONE || zone > LAST_ZONE) { fprintf(stderr, "%s(): Invalid arguments!\n", __FUNCTION__); errno = EINVAL; return NULL; diff --git a/libntfs/mft.c b/libntfs/mft.c index f8497730..5e3b2de1 100644 --- a/libntfs/mft.c +++ b/libntfs/mft.c @@ -129,7 +129,7 @@ int ntfs_mft_records_write(const ntfs_volume *vol, const MFT_REF mref, if (m + count > vol->nr_mft_records) { // TODO: Need to extend $MFT. This is not just normal attribute // extension as many rules need to be observed. (AIA) - if (bmirr); + if (bmirr) free(bmirr); errno = ENOTSUP; return -1; @@ -253,9 +253,9 @@ read_failed: * * On error return NULL with errno set to the error code. */ -ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, u64 start) +ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, s64 start) { - if (!vol || !vol->mftbmp_na) { + if (!vol || !vol->mftbmp_na || start < -1) { errno = EINVAL; return NULL; } diff --git a/libntfs/runlist.c b/libntfs/runlist.c index c2257223..1a066c5e 100644 --- a/libntfs/runlist.c +++ b/libntfs/runlist.c @@ -727,8 +727,8 @@ runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol, LCN lcn; /* Current lcn. */ s64 deltaxcn; /* Change in [vl]cn. */ runlist_element *rl; /* The output runlist. */ - u8 *buf; /* Current position in mapping pairs array. */ - u8 *attr_end; /* End of attribute. */ + const u8 *buf; /* Current position in mapping pairs array. */ + const u8 *attr_end; /* End of attribute. */ int err, rlsize; /* Size of runlist buffer. */ u16 rlpos; /* Current runlist position in units of runlist_elements. */ @@ -746,9 +746,9 @@ runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol, vcn = sle64_to_cpu(attr->lowest_vcn); lcn = 0; /* Get start of the mapping pairs array. */ - buf = (u8*)attr + le16_to_cpu(attr->mapping_pairs_offset); - attr_end = (u8*)attr + le32_to_cpu(attr->length); - if (buf < (u8*)attr || buf > attr_end) { + buf = (const u8*)attr + le16_to_cpu(attr->mapping_pairs_offset); + attr_end = (const u8*)attr + le32_to_cpu(attr->length); + if (buf < (const u8*)attr || buf > attr_end) { Dputs("Corrupt attribute."); errno = EIO; return NULL; diff --git a/libntfs/volume.c b/libntfs/volume.c index 7099a2af..c60d1f9f 100644 --- a/libntfs/volume.c +++ b/libntfs/volume.c @@ -976,7 +976,8 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag) * function returns success. If it returns an error then nothing has been done * so it is safe to continue using @vol. */ -int ntfs_device_umount(ntfs_volume *vol, const BOOL force) +int ntfs_device_umount(ntfs_volume *vol, + const BOOL force __attribute__((unused))) { if (!vol) { errno = EINVAL; @@ -1008,7 +1009,8 @@ int ntfs_device_umount(ntfs_volume *vol, const BOOL force) * function returns success. If it returns an error then nothing has been done * so it is safe to continue using @vol. */ -int ntfs_umount(ntfs_volume *vol, const BOOL force) +int ntfs_umount(ntfs_volume *vol, + const BOOL force __attribute__((unused))) { struct ntfs_device *dev; diff --git a/ntfsprogs/utils.c b/ntfsprogs/utils.c index 6b6b7fc8..7b60db58 100644 --- a/ntfsprogs/utils.c +++ b/ntfsprogs/utils.c @@ -298,23 +298,23 @@ int utils_parse_range (const char *string, s64 *start, s64 *finish, BOOL scale) /** * ntfs2utc - Convert an NTFS time to Unix time - * @time: An NTFS time in 100ns units since 1601 + * @ntfs_time: An NTFS time in 100ns units since 1601 * * NTFS stores times as the number of 100ns intervals since January 1st 1601 at * 00:00 UTC. This system will not suffer from Y2K problems until ~57000AD. * * Return: n A Unix time (number of seconds since 1970) */ -time_t ntfs2utc (s64 time) +time_t ntfs2utc (s64 ntfs_time) { - return (time - (NTFS_TIME_OFFSET)) / 10000000; + return (ntfs_time - (NTFS_TIME_OFFSET)) / 10000000; } /** * utc2ntfs - Convert Linux time to NTFS time - * @time: Linux time to convert to NTFS + * @utc_time: Linux time to convert to NTFS * - * Convert the Linux time @time to its corresponding NTFS time. + * Convert the Linux time @utc_time to its corresponding NTFS time. * * Linux stores time in a long at present and measures it as the number of * 1-second intervals since 1st January 1970, 00:00:00 UTC. @@ -325,10 +325,10 @@ time_t ntfs2utc (s64 time) * * Return: n An NTFS time (100ns units since Jan 1601) */ -s64 utc2ntfs (time_t time) +s64 utc2ntfs (time_t utc_time) { /* Convert to 100ns intervals and then add the NTFS time offset. */ - return (s64)time * 10000000 + NTFS_TIME_OFFSET; + return (s64)utc_time * 10000000 + NTFS_TIME_OFFSET; } /** diff --git a/ntfsprogs/utils.h b/ntfsprogs/utils.h index 6841f11e..e4bbffbf 100644 --- a/ntfsprogs/utils.h +++ b/ntfsprogs/utils.h @@ -80,8 +80,8 @@ int utils_mftrec_in_use (ntfs_volume *vol, MFT_REF mref); int utils_is_metadata (ntfs_inode *inode); ntfs_inode * utils_pathname_to_inode (ntfs_volume *vol, ntfs_inode *parent, const char *pathname); -time_t ntfs2utc (s64 time); -s64 utc2ntfs (time_t time); +time_t ntfs2utc (s64 ntfs_time); +s64 utc2ntfs (time_t utc_time); ATTR_RECORD * find_attribute (const ATTR_TYPES type, ntfs_attr_search_ctx *ctx); ATTR_RECORD * find_first_attribute (const ATTR_TYPES type, MFT_RECORD *mft);