Commit aa33c44f authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: Finish off sparse annotation.

- Fix all the sparse bitwise warnings.  Had to change all the enums
  storing little endian values to #defines because we cannot set enums
  to be little endian so we had lots of bitwise warnings from sparse.
Signed-off-by: default avatarAnton Altaparmakov <aia21@cantab.net>
parent 2a54ecd7
......@@ -48,6 +48,9 @@ ToDo/Notes:
Affected files are fs/ntfs/layout.h, logfile.h, and time.h.
- Do proper type casting when using ntfs_is_*_recordp() in
fs/ntfs/logfile.c, mft.c, and super.c.
- Fix all the sparse bitwise warnings. Had to change all the enums
storing little endian values to #defines because we cannot set enums
to be little endian so we had lots of bitwise warnings from sparse.
2.1.18 - Fix scheduling latencies at mount time as well as an endianness bug.
......
......@@ -1203,7 +1203,7 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
* Warning: Never use @val when looking for attribute types which can be
* non-resident as this most likely will result in a crash!
*/
static int ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
static int ntfs_attr_find(const ATTR_TYPE type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic,
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
{
......@@ -1475,7 +1475,7 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start,
* On actual error, ntfs_external_attr_find() returns -EIO. In this case
* @ctx->attr is undefined and in particular do not rely on it not changing.
*/
static int ntfs_external_attr_find(const ATTR_TYPES type,
static int ntfs_external_attr_find(const ATTR_TYPE type,
const ntfschar *name, const u32 name_len,
const IGNORE_CASE_BOOL ic, const VCN lowest_vcn,
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
......@@ -1620,7 +1620,8 @@ static int ntfs_external_attr_find(const ATTR_TYPES type,
} else {
/* We want an extent record. */
ctx->mrec = map_extent_mft_record(base_ni,
al_entry->mft_reference, &ni);
le64_to_cpu(
al_entry->mft_reference), &ni);
ctx->ntfs_ino = ni;
if (IS_ERR(ctx->mrec)) {
ntfs_error(vol->sb, "Failed to map "
......@@ -1799,7 +1800,7 @@ static int ntfs_external_attr_find(const ATTR_TYPES type,
* When -errno != -ENOENT, an error occured during the lookup. @ctx->attr is
* then undefined and in particular you should not rely on it not changing.
*/
int ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic,
const VCN lowest_vcn, const u8 *val, const u32 val_len,
ntfs_attr_search_ctx *ctx)
......
......@@ -81,7 +81,7 @@ extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
const BOOL need_write);
int ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic,
const VCN lowest_vcn, const u8 *val, const u32 val_len,
ntfs_attr_search_ctx *ctx);
......
......@@ -97,24 +97,26 @@ static ntfs_collate_func_t ntfs_do_collate0x1[4] = {
* For speed we use the collation rule @cr as an index into two tables of
* function pointers to call the appropriate collation function.
*/
int ntfs_collate(ntfs_volume *vol, COLLATION_RULES cr,
int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
const void *data1, const int data1_len,
const void *data2, const int data2_len) {
int i;
ntfs_debug("Entering.");
/*
* FIXME: At the moment we only support COLLATION_BINARY and
* COLLATION_NTOFS_ULONG, so we BUG() for everything else for now.
*/
BUG_ON(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG);
cr = le32_to_cpu(cr);
BUG_ON(cr < 0);
if (cr <= 0x02)
return ntfs_do_collate0x0[cr](vol, data1, data1_len,
i = le32_to_cpu(cr);
BUG_ON(i < 0);
if (i <= 0x02)
return ntfs_do_collate0x0[i](vol, data1, data1_len,
data2, data2_len);
BUG_ON(cr < 0x10);
cr -= 0x10;
if (likely(cr <= 3))
return ntfs_do_collate0x1[cr](vol, data1, data1_len,
BUG_ON(i < 0x10);
i -= 0x10;
if (likely(i <= 3))
return ntfs_do_collate0x1[i](vol, data1, data1_len,
data2, data2_len);
BUG();
return 0;
......
......@@ -26,7 +26,9 @@
#include "types.h"
#include "volume.h"
static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULES cr) {
static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULE cr) {
int i;
/*
* FIXME: At the moment we only support COLLATION_BINARY and
* COLLATION_NTOFS_ULONG, so we return false for everything else for
......@@ -34,14 +36,14 @@ static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULES cr) {
*/
if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG))
return FALSE;
cr = le32_to_cpu(cr);
if (likely(((cr >= 0) && (cr <= 0x02)) ||
((cr >= 0x10) && (cr <= 0x13))))
i = le32_to_cpu(cr);
if (likely(((i >= 0) && (i <= 0x02)) ||
((i >= 0x10) && (i <= 0x13))))
return TRUE;
return FALSE;
}
extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULES cr,
extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
const void *data1, const int data1_len,
const void *data2, const int data2_len);
......
......@@ -203,7 +203,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
* position in the compression block is one byte before its end so the
* first two checks do not detect it.
*/
if (cb == cb_end || !le16_to_cpup((u16*)cb) ||
if (cb == cb_end || !le16_to_cpup((le16*)cb) ||
(*dest_index == dest_max_index &&
*dest_ofs == dest_max_ofs)) {
int i;
......@@ -255,7 +255,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
/* Setup the current sub-block source pointers and validate range. */
cb_sb_start = cb;
cb_sb_end = cb_sb_start + (le16_to_cpup((u16*)cb) & NTFS_SB_SIZE_MASK)
cb_sb_end = cb_sb_start + (le16_to_cpup((le16*)cb) & NTFS_SB_SIZE_MASK)
+ 3;
if (cb_sb_end > cb_end)
goto return_overflow;
......@@ -277,7 +277,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
dp_addr = (u8*)page_address(dp) + do_sb_start;
/* Now, we are ready to process the current sub-block (sb). */
if (!(le16_to_cpup((u16*)cb) & NTFS_SB_IS_COMPRESSED)) {
if (!(le16_to_cpup((le16*)cb) & NTFS_SB_IS_COMPRESSED)) {
ntfs_debug("Found uncompressed sub-block.");
/* This sb is not compressed, just copy it into destination. */
......@@ -382,7 +382,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
lg++;
/* Get the phrase token into i. */
pt = le16_to_cpup((u16*)cb);
pt = le16_to_cpup((le16*)cb);
/*
* Calculate starting position of the byte sequence in
......
......@@ -214,7 +214,7 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
* value with IS_ERR() and if true, the function failed and the error code is
* obtained from PTR_ERR().
*/
struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPES type,
struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
ntfschar *name, u32 name_len)
{
struct inode *vi;
......@@ -2404,7 +2404,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
*/
int ntfs_write_inode(struct inode *vi, int sync)
{
s64 nt;
sle64 nt;
ntfs_inode *ni = NTFS_I(vi);
ntfs_attr_search_ctx *ctx;
MFT_RECORD *m;
......
......@@ -53,7 +53,7 @@ struct _ntfs_inode {
* name_len = 0 for files and name = I30 (global constant) and
* name_len = 4 for directories.
*/
ATTR_TYPES type; /* Attribute type of this fake inode. */
ATTR_TYPE type; /* Attribute type of this fake inode. */
ntfschar *name; /* Attribute name of this fake inode. */
u32 name_len; /* Attribute name length of this fake inode. */
runlist runlist; /* If state has the NI_NonResident bit set,
......@@ -96,7 +96,7 @@ struct _ntfs_inode {
u32 block_size; /* Size of an index block. */
u32 vcn_size; /* Size of a vcn in this
index. */
COLLATION_RULES collation_rule; /* The collation rule
COLLATION_RULE collation_rule; /* The collation rule
for the index. */
u8 block_size_bits; /* Log2 of the above. */
u8 vcn_size_bits; /* Log2 of the above. */
......@@ -252,7 +252,7 @@ typedef struct {
unsigned long mft_no;
ntfschar *name;
u32 name_len;
ATTR_TYPES type;
ATTR_TYPE type;
} ntfs_attr;
typedef int (*test_t)(struct inode *, void *);
......@@ -260,7 +260,7 @@ typedef int (*test_t)(struct inode *, void *);
extern int ntfs_test_inode(struct inode *vi, ntfs_attr *na);
extern struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no);
extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPES type,
extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
ntfschar *name, u32 name_len);
extern struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
u32 name_len);
......
This diff is collapsed.
......@@ -67,7 +67,7 @@
typedef struct {
/*Ofs*/
/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
/* 0*/ NTFS_RECORD_TYPES magic;/* The magic is "RSTR". */
/* 0*/ NTFS_RECORD_TYPE magic; /* The magic is "RSTR". */
/* 4*/ le16 usa_ofs; /* See NTFS_RECORD definition in layout.h.
When creating, set this to be immediately
after this header structure (without any
......
......@@ -44,7 +44,7 @@ static void __format_mft_record(MFT_RECORD *m, const int size,
m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1);
m->usa_count = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1);
/* Set the update sequence number to 1. */
*(u16*)((char*)m + ((sizeof(MFT_RECORD) + 1) & ~1)) = cpu_to_le16(1);
*(le16*)((char*)m + ((sizeof(MFT_RECORD) + 1) & ~1)) = cpu_to_le16(1);
m->lsn = cpu_to_le64(0LL);
m->sequence_number = cpu_to_le16(1);
m->link_count = cpu_to_le16(0);
......@@ -311,11 +311,11 @@ void unmap_mft_record(ntfs_inode *ni)
/**
* map_extent_mft_record - load an extent inode and attach it to its base
* @base_ni: base ntfs inode
* @mref: mft reference of the extent inode to load (in little endian)
* @mref: mft reference of the extent inode to load
* @ntfs_ino: on successful return, pointer to the ntfs_inode structure
*
* Load the extent mft record @mref and attach it to its base inode @base_ni.
* Return the mapped extent mft record if IS_ERR(result) is false. Otherwise
* Return the mapped extent mft record if IS_ERR(result) is false. Otherwise
* PTR_ERR(result) gives the negative error code.
*
* On successful return, @ntfs_ino contains a pointer to the ntfs_inode
......@@ -328,8 +328,8 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
ntfs_inode *ni = NULL;
ntfs_inode **extent_nis = NULL;
int i;
unsigned long mft_no = MREF_LE(mref);
u16 seq_no = MSEQNO_LE(mref);
unsigned long mft_no = MREF(mref);
u16 seq_no = MSEQNO(mref);
BOOL destroy_ni = FALSE;
ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).",
......
......@@ -122,8 +122,9 @@ int post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
*/
int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
{
le16 *usa_pos, *data_pos;
u16 usa_ofs, usa_count, usn;
u16 *usa_pos, *data_pos;
le16 le_usn;
/* Sanity check + only fixup if it makes sense. */
if (!b || ntfs_is_baad_record(b->magic) ||
......@@ -140,7 +141,7 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
(size >> NTFS_BLOCK_SIZE_BITS) != usa_count)
return -EINVAL;
/* Position of usn in update sequence array. */
usa_pos = (u16*)((u8*)b + usa_ofs);
usa_pos = (le16*)((u8*)b + usa_ofs);
/*
* Cyclically increment the update sequence number
* (skipping 0 and -1, i.e. 0xffff).
......@@ -148,10 +149,10 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
usn = le16_to_cpup(usa_pos) + 1;
if (usn == 0xffff || !usn)
usn = 1;
usn = cpu_to_le16(usn);
*usa_pos = usn;
le_usn = cpu_to_le16(usn);
*usa_pos = le_usn;
/* Position in data of first u16 that needs fixing up. */
data_pos = (u16*)b + NTFS_BLOCK_SIZE/sizeof(u16) - 1;
data_pos = (le16*)b + NTFS_BLOCK_SIZE/sizeof(le16) - 1;
/* Fixup all sectors. */
while (usa_count--) {
/*
......@@ -160,9 +161,9 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
*/
*(++usa_pos) = *data_pos;
/* Apply fixup to data. */
*data_pos = usn;
*data_pos = le_usn;
/* Increment position in data as well. */
data_pos += NTFS_BLOCK_SIZE/sizeof(u16);
data_pos += NTFS_BLOCK_SIZE/sizeof(le16);
}
return 0;
}
......@@ -177,16 +178,16 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
*/
void post_write_mst_fixup(NTFS_RECORD *b)
{
u16 *usa_pos, *data_pos;
le16 *usa_pos, *data_pos;
u16 usa_ofs = le16_to_cpu(b->usa_ofs);
u16 usa_count = le16_to_cpu(b->usa_count) - 1;
/* Position of usn in update sequence array. */
usa_pos = (u16*)b + usa_ofs/sizeof(u16);
usa_pos = (le16*)b + usa_ofs/sizeof(le16);
/* Position in protected data of first u16 that needs fixing up. */
data_pos = (u16*)b + NTFS_BLOCK_SIZE/sizeof(u16) - 1;
data_pos = (le16*)b + NTFS_BLOCK_SIZE/sizeof(le16) - 1;
/* Fixup all sectors. */
while (usa_count--) {
......@@ -197,6 +198,6 @@ void post_write_mst_fixup(NTFS_RECORD *b)
*data_pos = *(++usa_pos);
/* Increment position in data as well. */
data_pos += NTFS_BLOCK_SIZE/sizeof(u16);
data_pos += NTFS_BLOCK_SIZE/sizeof(le16);
}
}
......@@ -37,7 +37,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
{
ntfs_index_context *ictx;
QUOTA_CONTROL_ENTRY *qce;
const u32 qid = QUOTA_DEFAULTS_ID;
const le32 qid = QUOTA_DEFAULTS_ID;
int err;
ntfs_debug("Entering.");
......
......@@ -322,7 +322,7 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags)
int err;
ntfs_debug("Entering, old flags = 0x%x, new flags = 0x%x.",
vol->vol_flags, flags);
le16_to_cpu(vol->vol_flags), le16_to_cpu(flags));
if (vol->vol_flags == flags)
goto done;
BUG_ON(!ni);
......@@ -386,7 +386,8 @@ static inline int ntfs_set_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags)
static inline int ntfs_clear_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags)
{
flags &= VOLUME_FLAGS_MASK;
return ntfs_write_volume_flags(vol, vol->vol_flags & ~flags);
flags = vol->vol_flags & cpu_to_le16(~le16_to_cpu(flags));
return ntfs_write_volume_flags(vol, flags);
}
#endif /* NTFS_RW */
......
......@@ -96,7 +96,7 @@ int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
const ntfschar *upcase, const u32 upcase_len)
{
u32 cnt, min_len;
ntfschar c1, c2;
u16 c1, c2;
min_len = name1_len;
if (name1_len > name2_len)
......@@ -144,7 +144,7 @@ int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
*/
int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n)
{
ntfschar c1, c2;
u16 c1, c2;
size_t i;
for (i = 0; i < n; ++i) {
......@@ -181,8 +181,8 @@ int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n)
int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n,
const ntfschar *upcase, const u32 upcase_size)
{
ntfschar c1, c2;
size_t i;
u16 c1, c2;
for (i = 0; i < n; ++i) {
if ((c1 = le16_to_cpu(s1[i])) < upcase_size)
......@@ -203,7 +203,7 @@ void ntfs_upcase_name(ntfschar *name, u32 name_len, const ntfschar *upcase,
const u32 upcase_len)
{
u32 i;
ntfschar u;
u16 u;
for (i = 0; i < name_len; i++)
if ((u = le16_to_cpu(name[i])) < upcase_len)
......
......@@ -3,7 +3,7 @@
* Part of the Linux-NTFS project.
*
* Copyright (c) 2001 Richard Russon <ntfs@flatcap.org>
* Copyright (c) 2001-2003 Anton Altaparmakov
* Copyright (c) 2001-2004 Anton Altaparmakov
*
* Modified for mkntfs inclusion 9 June 2001 by Anton Altaparmakov.
* Modified for kernel inclusion 10 September 2001 by Anton Altparmakov.
......@@ -87,4 +87,3 @@ ntfschar *generate_default_upcase(void)
uc[uc_word_table[r][0]] = cpu_to_le16(uc_word_table[r][1]);
return uc;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment