Replace all le16 non-zero test conditions with "!le16_cmpz(...)".

edge.strict_endians
Erik Larsson 2016-01-28 08:28:37 +01:00
parent c29924872f
commit 90697bb5ab
10 changed files with 30 additions and 28 deletions

View File

@ -310,4 +310,6 @@
#define be32_eq(a, b) ((a) == (b))
#define le16_cmpz(a) (!(a))
#endif /* defined _NTFS_ENDIANS_H */

View File

@ -837,13 +837,13 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
pauthace->mask |= pnewace->mask;
} else {
pauthace = pnewace;
if (inherited)
if (!le16_cmpz(inherited))
pnewace->flags |= INHERITED_ACE;
dst += acesz;
newcnt++;
}
} else {
if (inherited)
if (!le16_cmpz(inherited))
pnewace->flags |= INHERITED_ACE;
dst += acesz;
newcnt++;
@ -871,7 +871,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
pnewace->flags &= ~(OBJECT_INHERIT_ACE
| CONTAINER_INHERIT_ACE
| INHERIT_ONLY_ACE);
if (inherited)
if (!le16_cmpz(inherited))
pnewace->flags |= INHERITED_ACE;
if ((pnewace->type == ACCESS_ALLOWED_ACE_TYPE)
&& pownerace
@ -889,7 +889,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
pnewace->flags &= ~(OBJECT_INHERIT_ACE
| CONTAINER_INHERIT_ACE
| INHERIT_ONLY_ACE);
if (inherited)
if (!le16_cmpz(inherited))
pnewace->flags |= INHERITED_ACE;
dst += gsidsz + 8;
newcnt++;
@ -922,7 +922,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
else
pnewace->flags &= ~INHERIT_ONLY_ACE;
}
if (inherited)
if (!le16_cmpz(inherited))
pnewace->flags |= INHERITED_ACE;
/*
* Prepare grouping similar ACE for authenticated users

View File

@ -163,7 +163,7 @@ s64 ntfs_get_attribute_value(const ntfs_volume *vol,
* attribute. Windows does not complain about invalid flags and chkdsk
* does not detect or fix them so we need to cope with it, too.
*/
if (!le32_eq(a->type, AT_ATTRIBUTE_LIST) && a->flags) {
if (!le32_eq(a->type, AT_ATTRIBUTE_LIST) && !le16_cmpz(a->flags)) {
ntfs_log_error("Non-zero (%04x) attribute flags. Cannot handle "
"this yet.\n", le16_to_cpu(a->flags));
errno = EOPNOTSUPP;
@ -503,14 +503,14 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
sle64_to_cpu(a->allocated_size),
sle64_to_cpu(a->data_size),
sle64_to_cpu(a->initialized_size),
cs ? sle64_to_cpu(a->compressed_size) : 0,
cs ? a->compression_unit : 0);
!le16_cmpz(cs) ? sle64_to_cpu(a->compressed_size) : 0,
!le16_cmpz(cs) ? a->compression_unit : 0);
} else {
s64 l = le32_to_cpu(a->value_length);
ntfs_attr_init(na, FALSE, a->flags,
a->flags & ATTR_IS_ENCRYPTED,
a->flags & ATTR_IS_SPARSE, (l + 7) & ~7, l, l,
cs ? (l + 7) & ~7 : 0, 0);
!le16_cmpz(cs) ? (l + 7) & ~7 : 0, 0);
}
ntfs_attr_put_search_ctx(ctx);
out:
@ -5819,11 +5819,11 @@ retry:
a->allocated_size = cpu_to_sle64(na->allocated_size);
spcomp = na->data_flags
& (ATTR_IS_COMPRESSED | ATTR_IS_SPARSE);
if (spcomp)
if (!le16_cmpz(spcomp))
a->compressed_size = cpu_to_sle64(na->compressed_size);
if (le32_eq(na->type, AT_DATA) && (na->name == AT_UNNAMED)) {
na->ni->allocated_size
= (spcomp
= (!le16_cmpz(spcomp)
? na->compressed_size
: na->allocated_size);
NInoFileNameSetDirty(na->ni);

View File

@ -2026,7 +2026,7 @@ search:
ntfs_log_error("Could not delete inode cache entry for %s\n",
pathname);
#endif
if (ni->mrec->link_count) {
if (!le16_cmpz(ni->mrec->link_count)) {
ntfs_inode_update_times(ni, NTFS_UPDATE_CTIME);
goto ok;
}

View File

@ -1457,10 +1457,10 @@ found_free_rec:
free(m);
goto undo_mftbmp_alloc;
}
if (seq_no)
if (!le16_cmpz(seq_no))
m->sequence_number = seq_no;
seq_no = usn;
if (seq_no && !le16_eq(seq_no, const_cpu_to_le16(0xffff)))
if (!le16_cmpz(seq_no) && !le16_eq(seq_no, const_cpu_to_le16(0xffff)))
*(le16*)((u8*)m + le16_to_cpu(m->usa_ofs)) = usn;
/* Set the mft record itself in use. */
m->flags |= MFT_RECORD_IN_USE;
@ -1760,10 +1760,10 @@ found_free_rec:
free(m);
goto undo_mftbmp_alloc;
}
if (seq_no)
if (!le16_cmpz(seq_no))
m->sequence_number = seq_no;
seq_no = usn;
if (seq_no && !le16_eq(seq_no, const_cpu_to_le16(0xffff)))
if (!le16_cmpz(seq_no) && !le16_eq(seq_no, const_cpu_to_le16(0xffff)))
*(le16*)((u8*)m + le16_to_cpu(m->usa_ofs)) = usn;
/* Set the mft record itself in use. */
m->flags |= MFT_RECORD_IN_USE;

View File

@ -507,7 +507,7 @@ static char *ntfs_get_fulllink(ntfs_volume *vol, ntfschar *junction,
*/
if ((count >= 7)
&& !memcmp(junction,dir_junction_head,8)
&& junction[4]
&& !le16_cmpz(junction[4])
&& le16_eq(junction[5], const_cpu_to_le16(':'))
&& le16_eq(junction[6], const_cpu_to_le16('\\')))
kind = DIR_JUNCTION;
@ -529,7 +529,7 @@ static char *ntfs_get_fulllink(ntfs_volume *vol, ntfschar *junction,
*/
if ((kind == DIR_JUNCTION)
&& (count >= 7)
&& junction[7]
&& !le16_cmpz(junction[7])
&& !ntfs_drive_letter(vol, junction[4])) {
target = search_absolute(vol,&junction[7],count - 7, isdir);
if (target) {
@ -609,7 +609,7 @@ static char *ntfs_get_abslink(ntfs_volume *vol, ntfschar *junction,
* where \ is an individual char and x a non-null char
*/
if ((count >= 3)
&& junction[0]
&& !le16_cmpz(junction[0])
&& le16_eq(junction[1], const_cpu_to_le16(':'))
&& le16_eq(junction[2], const_cpu_to_le16('\\')))
kind = FULL_PATH;
@ -630,7 +630,7 @@ static char *ntfs_get_abslink(ntfs_volume *vol, ntfschar *junction,
*/
if (((kind == FULL_PATH)
&& (count >= 3)
&& junction[3]
&& !le16_cmpz(junction[3])
&& !ntfs_drive_letter(vol, junction[0]))
|| (kind == ABS_PATH)) {
if (kind == ABS_PATH)

View File

@ -456,7 +456,7 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
BOOL surrog;
surrog = FALSE;
for (i = 0; i < ins_len && ins[i]; i++) {
for (i = 0; i < ins_len && !le16_cmpz(ins[i]); i++) {
unsigned short c = le16_to_cpu(ins[i]);
if (surrog) {
if ((c >= 0xdc00) && (c < 0xe000)) {
@ -538,7 +538,7 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
t = *outs;
for (i = 0; i < ins_len && ins[i]; i++) {
for (i = 0; i < ins_len && !le16_cmpz(ins[i]); i++) {
unsigned short c = le16_to_cpu(ins[i]);
/* size not double-checked */
if (halfpair) {

View File

@ -2459,7 +2459,7 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name,
goto err_out;
}
a = ctx->attr;
if (a->non_resident || a->flags) {
if (a->non_resident || !le16_cmpz(a->flags)) {
err = -EINVAL;
goto err_out;
}

View File

@ -860,7 +860,7 @@ static BOOL attrlist_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
>> vol->cluster_size_bits;
levcn = cpu_to_le64(vcn);
while ((length > 0)
&& al->length
&& !le16_cmpz(al->length)
&& (!le32_eq(al->type, AT_DATA)
|| !sle64_eq(al->lowest_vcn, levcn))) {
length -= le16_to_cpu(al->length);
@ -868,7 +868,7 @@ static BOOL attrlist_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
((char*)al + le16_to_cpu(al->length));
}
if ((length > 0)
&& al->length
&& !le16_cmpz(al->length)
&& le32_eq(al->type, AT_DATA)
&& !al->name_length
&& sle64_eq(al->lowest_vcn, levcn)

View File

@ -821,7 +821,7 @@ static void ntfs_dump_filename(const char *indent,
le16_to_cpu(file_name_attr->packed_ea_size),
(unsigned)
le16_to_cpu(file_name_attr->packed_ea_size));
if (file_name_attr->reserved)
if (!le16_cmpz(file_name_attr->reserved))
printf("%sReserved:\t\t %d (0x%x)\n", indent,
(unsigned)
le16_to_cpu(file_name_attr->reserved),
@ -2188,7 +2188,7 @@ static void ntfs_dump_inode_general_info(ntfs_inode *inode)
(unsigned)le16_to_cpu(mrec->attrs_offset));
printf("MFT Record Flags:\t ");
if (inode_flags) {
if (!le16_cmpz(inode_flags)) {
if (MFT_RECORD_IN_USE & inode_flags) {
printf("IN_USE ");
inode_flags &= ~MFT_RECORD_IN_USE;
@ -2206,7 +2206,7 @@ static void ntfs_dump_inode_general_info(ntfs_inode *inode)
printf("VIEW_INDEX ");
inode_flags &= ~MFT_RECORD_IS_VIEW_INDEX;
}
if (inode_flags)
if (!le16_cmpz(inode_flags))
printf("UNKNOWN: 0x%04x", (unsigned)le16_to_cpu(
inode_flags));
} else {