From 85588b8e927089a03ae28885e7d589f0a130f8f0 Mon Sep 17 00:00:00 2001 From: Erik Larsson Date: Thu, 28 Jan 2016 08:28:59 +0100 Subject: [PATCH] Replace all le16 "not" negations with le16_not(...). --- include/ntfs-3g/endians.h | 2 ++ libntfs-3g/attrib.c | 10 +++++----- libntfs-3g/compress.c | 4 ++-- libntfs-3g/index.c | 4 ++-- libntfs-3g/mft.c | 2 +- ntfsprogs/mkntfs.c | 8 ++++---- ntfsprogs/ntfsck.c | 4 ++-- ntfsprogs/ntfsdump_logfile.c | 2 +- ntfsprogs/ntfsfallocate.c | 2 +- ntfsprogs/ntfsfix.c | 2 +- ntfsprogs/ntfsinfo.c | 14 +++++++------- ntfsprogs/ntfstruncate.c | 2 +- 12 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/ntfs-3g/endians.h b/include/ntfs-3g/endians.h index 339c688a..ee8e66ce 100644 --- a/include/ntfs-3g/endians.h +++ b/include/ntfs-3g/endians.h @@ -342,4 +342,6 @@ #define le64_xor(a, b) ((a) ^ (b)) +#define le16_not(a) (~(a)) + #endif /* defined _NTFS_ENDIANS_H */ diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 09764fd1..9803c959 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -467,7 +467,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type, * Also prevent compression on NTFS version < 3.0 * or cluster size > 4K or compression is disabled */ - a->flags = le16_and(a->flags, ~ATTR_COMPRESSION_MASK); + a->flags = le16_and(a->flags, le16_not(ATTR_COMPRESSION_MASK)); if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED) && (ni->vol->major_ver >= 3) && NVolCompression(ni->vol) @@ -4386,7 +4386,7 @@ int ntfs_attr_set_flags(ntfs_inode *ni, ATTR_TYPES type, const ntfschar *name, if (!ntfs_attr_lookup(type, name, name_len, CASE_SENSITIVE, 0, NULL, 0, ctx)) { /* do the requested change (all small endian le16) */ - ctx->attr->flags = le16_or(le16_and(ctx->attr->flags, ~mask), + ctx->attr->flags = le16_or(le16_and(ctx->attr->flags, le16_not(mask)), le16_and(flags, mask)); NInoSetDirty(ni); res = 0; @@ -4887,14 +4887,14 @@ int ntfs_attr_make_non_resident(ntfs_attr *na, * The decisions about compression can only be made when * creating/recreating the stream, not when making non resident. */ - a->flags = le16_and(a->flags, ~(le16_or(ATTR_IS_SPARSE, ATTR_IS_ENCRYPTED))); + a->flags = le16_and(a->flags, le16_not(le16_or(ATTR_IS_SPARSE, ATTR_IS_ENCRYPTED))); if (le16_eq(le16_and(a->flags, ATTR_COMPRESSION_MASK), ATTR_IS_COMPRESSED)) { /* support only ATTR_IS_COMPRESSED compression mode */ a->compression_unit = STANDARD_COMPRESSION_UNIT; a->compressed_size = const_cpu_to_le64(0); } else { a->compression_unit = 0; - a->flags = le16_and(a->flags, ~ATTR_COMPRESSION_MASK); + a->flags = le16_and(a->flags, le16_not(ATTR_COMPRESSION_MASK)); na->data_flags = a->flags; } @@ -5498,7 +5498,7 @@ static int ntfs_attr_update_meta(ATTR_RECORD *a, ntfs_attr *na, MFT_RECORD *m, le16_andz(a->flags, ATTR_IS_COMPRESSED)) { NAttrClearSparse(na); - a->flags = le16_and(a->flags, ~ATTR_IS_SPARSE); + a->flags = le16_and(a->flags, le16_not(ATTR_IS_SPARSE)); na->data_flags = a->flags; a->compression_unit = 0; diff --git a/libntfs-3g/compress.c b/libntfs-3g/compress.c index c893d5f5..89b3fde8 100644 --- a/libntfs-3g/compress.c +++ b/libntfs-3g/compress.c @@ -838,7 +838,7 @@ do_next_cb: to_read = min(count, cb_size - ofs); ofs += vcn << vol->cluster_size_bits; NAttrClearCompressed(na); - na->data_flags = le16_and(na->data_flags, ~ATTR_COMPRESSION_MASK); + na->data_flags = le16_and(na->data_flags, le16_not(ATTR_COMPRESSION_MASK)); tdata_size = na->data_size; tinitialized_size = na->initialized_size; na->data_size = na->initialized_size = na->allocated_size; @@ -896,7 +896,7 @@ do_next_cb: */ to_read = cb_size; NAttrClearCompressed(na); - na->data_flags = le16_and(na->data_flags, ~ATTR_COMPRESSION_MASK); + na->data_flags = le16_and(na->data_flags, le16_not(ATTR_COMPRESSION_MASK)); tdata_size = na->data_size; tinitialized_size = na->initialized_size; na->data_size = na->initialized_size = na->allocated_size; diff --git a/libntfs-3g/index.c b/libntfs-3g/index.c index e9fc27b5..32e74e00 100644 --- a/libntfs-3g/index.c +++ b/libntfs-3g/index.c @@ -382,7 +382,7 @@ static INDEX_ENTRY *ntfs_ie_dup_novcn(INDEX_ENTRY *ie) dup = ntfs_malloc(size); if (dup) { memcpy(dup, ie, size); - dup->ie_flags = le16_and(dup->ie_flags, ~INDEX_ENTRY_NODE); + dup->ie_flags = le16_and(dup->ie_flags, le16_not(INDEX_ENTRY_NODE)); dup->length = cpu_to_le16(size); } return dup; @@ -1597,7 +1597,7 @@ static void ntfs_ir_leafify(ntfs_index_context *icx, INDEX_HEADER *ih) ntfs_log_trace("Entering\n"); ie = ntfs_ie_get_first(ih); - ie->ie_flags = le16_and(ie->ie_flags, ~INDEX_ENTRY_NODE); + ie->ie_flags = le16_and(ie->ie_flags, le16_not(INDEX_ENTRY_NODE)); ie->length = cpu_to_le16(le16_to_cpu(ie->length) - sizeof(VCN)); ih->index_length = cpu_to_le32(le32_to_cpu(ih->index_length) - sizeof(VCN)); diff --git a/libntfs-3g/mft.c b/libntfs-3g/mft.c index cae67278..ca732ce0 100644 --- a/libntfs-3g/mft.c +++ b/libntfs-3g/mft.c @@ -1870,7 +1870,7 @@ int ntfs_mft_record_free(ntfs_volume *vol, ntfs_inode *ni) mft_no = ni->mft_no; /* Mark the mft record as not in use. */ - ni->mrec->flags = le16_and(ni->mrec->flags, ~MFT_RECORD_IN_USE); + ni->mrec->flags = le16_and(ni->mrec->flags, le16_not(MFT_RECORD_IN_USE)); /* Increment the sequence number, skipping zero, if it is not zero. */ old_seq_no = ni->mrec->sequence_number; diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 3203b2e2..b1785c63 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -1562,10 +1562,10 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m, if (name_len) memcpy((char*)a + hdr_size, uname, name_len << 1); if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) { - if (!le16_andz(flags, le16_and(ATTR_COMPRESSION_MASK, ~ATTR_IS_COMPRESSED))) { + if (!le16_andz(flags, le16_and(ATTR_COMPRESSION_MASK, le16_not(ATTR_IS_COMPRESSED)))) { ntfs_log_error("Unknown compression format. Reverting " "to standard compression.\n"); - a->flags = le16_and(a->flags, ~ATTR_COMPRESSION_MASK); + a->flags = le16_and(a->flags, le16_not(ATTR_COMPRESSION_MASK)); a->flags = le16_or(a->flags, ATTR_IS_COMPRESSED); } a->compression_unit = 4; @@ -1759,10 +1759,10 @@ static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, if (name_len) memcpy((char*)a + hdr_size, uname, name_len << 1); if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) { - if (!le16_andz(flags, le16_and(ATTR_COMPRESSION_MASK, ~ATTR_IS_COMPRESSED))) { + if (!le16_andz(flags, le16_and(ATTR_COMPRESSION_MASK, le16_not(ATTR_IS_COMPRESSED)))) { ntfs_log_error("Unknown compression format. Reverting " "to standard compression.\n"); - a->flags = le16_and(a->flags, ~ATTR_COMPRESSION_MASK); + a->flags = le16_and(a->flags, le16_not(ATTR_COMPRESSION_MASK)); a->flags = le16_or(a->flags, ATTR_IS_COMPRESSED); } a->compression_unit = 4; diff --git a/ntfsprogs/ntfsck.c b/ntfsprogs/ntfsck.c index d6bca813..948f9617 100644 --- a/ntfsprogs/ntfsck.c +++ b/ntfsprogs/ntfsck.c @@ -469,7 +469,7 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec, // todo: instance is unique. // Check flags. - if (!le16_andz(attr_rec->flags, ~(const_cpu_to_le16(0xc0ff)))) { + if (!le16_andz(attr_rec->flags, le16_not(const_cpu_to_le16(0xc0ff)))) { check_failed("Attribute %lld:0x%x Unknown flags (0x%x).\n", (long long)current_mft_record, (int)attr_type, (int)le16_to_cpu(attr_rec->flags)); @@ -796,7 +796,7 @@ static int reset_dirty(ntfs_volume *vol) ntfs_log_verbose("Resetting dirty flag.\n"); - flags = le16_and(vol->flags, ~VOLUME_IS_DIRTY); + flags = le16_and(vol->flags, le16_not(VOLUME_IS_DIRTY)); if (ntfs_volume_write_flags(vol, flags)) { ntfs_log_error("Error setting volume flags.\n"); diff --git a/ntfsprogs/ntfsdump_logfile.c b/ntfsprogs/ntfsdump_logfile.c index 807e0644..929f67a9 100644 --- a/ntfsprogs/ntfsdump_logfile.c +++ b/ntfsprogs/ntfsdump_logfile.c @@ -567,7 +567,7 @@ static void dump_log_record(LOG_RECORD *lr) ntfs_log_info(" LOG_RECORD_MULTI_PAGE"); _b = 1; } - if (!le16_andz(lr->flags, ~LOG_RECORD_MULTI_PAGE)) { + if (!le16_andz(lr->flags, le16_not(LOG_RECORD_MULTI_PAGE))) { if (_b) ntfs_log_info(" |"); ntfs_log_info(" Unknown flags"); diff --git a/ntfsprogs/ntfsfallocate.c b/ntfsprogs/ntfsfallocate.c index 828f91f1..616aab6a 100644 --- a/ntfsprogs/ntfsfallocate.c +++ b/ntfsprogs/ntfsfallocate.c @@ -548,7 +548,7 @@ static int ntfs_merge_allocation(ntfs_attr *na, runlist_element *rl, if (!le16_andz(na->data_flags, ATTR_IS_SPARSE)) { na->compressed_size += size; if (na->compressed_size >= na->allocated_size) { - na->data_flags = le16_and(na->data_flags, ~ATTR_IS_SPARSE); + na->data_flags = le16_and(na->data_flags, le16_not(ATTR_IS_SPARSE)); if (na->compressed_size > na->allocated_size) { ntfs_log_error("File size error : " "apparent %lld, " diff --git a/ntfsprogs/ntfsfix.c b/ntfsprogs/ntfsfix.c index 586b9a50..7859150b 100644 --- a/ntfsprogs/ntfsfix.c +++ b/ntfsprogs/ntfsfix.c @@ -1612,7 +1612,7 @@ int main(int argc, char **argv) * mounting was successful. */ if (opt.clear_dirty) - vol->flags = le16_and(vol->flags, ~VOLUME_IS_DIRTY); + vol->flags = le16_and(vol->flags, le16_not(VOLUME_IS_DIRTY)); else vol->flags = le16_or(vol->flags, VOLUME_IS_DIRTY); if (!opt.no_action && ntfs_volume_write_flags(vol, vol->flags)) { diff --git a/ntfsprogs/ntfsinfo.c b/ntfsprogs/ntfsinfo.c index 8b8582a0..17a7b042 100644 --- a/ntfsprogs/ntfsinfo.c +++ b/ntfsprogs/ntfsinfo.c @@ -983,7 +983,7 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc, printf("%s\tControl:\t\t 0x%04x\n", indent, le16_to_cpu(sec_desc->control)); - if (!le16_andz(~sec_desc->control, SE_SELF_RELATIVE)) { + if (!le16_andz(le16_not(sec_desc->control), SE_SELF_RELATIVE)) { SECURITY_DESCRIPTOR *sd = (SECURITY_DESCRIPTOR *)sec_desc; printf("%s\tOwner SID pointer:\t %p\n", indent, sd->owner); @@ -1152,10 +1152,10 @@ static void ntfs_dump_attr_volume_information(ATTR_RECORD *attr) (unsigned)le16_to_cpu(vol_information->flags)); } else printf("none set (0x0000)\n"); - if (!le16_andz(vol_information->flags, ~VOLUME_FLAGS_MASK)) + if (!le16_andz(vol_information->flags, le16_not(VOLUME_FLAGS_MASK))) printf("\t\t\t\t Unknown Flags: 0x%04x\n", le16_to_cpu(le16_and(vol_information->flags, - (~VOLUME_FLAGS_MASK)))); + le16_not(VOLUME_FLAGS_MASK)))); } static ntfschar NTFS_DATA_SDS[5] = { const_cpu_to_le16('$'), @@ -2191,20 +2191,20 @@ static void ntfs_dump_inode_general_info(ntfs_inode *inode) if (!le16_cmpz(inode_flags)) { if (!le16_andz(MFT_RECORD_IN_USE, inode_flags)) { printf("IN_USE "); - inode_flags = le16_and(inode_flags, ~MFT_RECORD_IN_USE); + inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IN_USE)); } if (!le16_andz(MFT_RECORD_IS_DIRECTORY, inode_flags)) { printf("DIRECTORY "); - inode_flags = le16_and(inode_flags, ~MFT_RECORD_IS_DIRECTORY); + inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IS_DIRECTORY)); } /* The meaning of IS_4 is illusive but not its existence. */ if (!le16_andz(MFT_RECORD_IS_4, inode_flags)) { printf("IS_4 "); - inode_flags = le16_and(inode_flags, ~MFT_RECORD_IS_4); + inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IS_4)); } if (!le16_andz(MFT_RECORD_IS_VIEW_INDEX, inode_flags)) { printf("VIEW_INDEX "); - inode_flags = le16_and(inode_flags, ~MFT_RECORD_IS_VIEW_INDEX); + inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IS_VIEW_INDEX)); } if (!le16_cmpz(inode_flags)) printf("UNKNOWN: 0x%04x", (unsigned)le16_to_cpu( diff --git a/ntfsprogs/ntfstruncate.c b/ntfsprogs/ntfstruncate.c index dea79d68..6a953701 100644 --- a/ntfsprogs/ntfstruncate.c +++ b/ntfsprogs/ntfstruncate.c @@ -589,7 +589,7 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a) printf("ATTR_IS_COMPRESSED"); first = FALSE; } - if (!le16_andz(le16_and(u, ATTR_COMPRESSION_MASK), ~ATTR_IS_COMPRESSED)) { + if (!le16_andz(le16_and(u, ATTR_COMPRESSION_MASK), le16_not(ATTR_IS_COMPRESSED))) { if (!first) printf(" | "); else