diff --git a/include/crucible/fs.h b/include/crucible/fs.h index 503c0c7..8d93de4 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -171,7 +171,7 @@ namespace crucible { ostream & operator<<(ostream &os, const BtrfsIoctlSearchKey &key); string btrfs_search_type_ntoa(unsigned type); - string btrfs_search_objectid_ntoa(unsigned objectid); + string btrfs_search_objectid_ntoa(uint64_t objectid); uint64_t btrfs_get_root_id(int fd); uint64_t btrfs_get_root_transid(int fd); diff --git a/include/crucible/ntoa.h b/include/crucible/ntoa.h index 24bc2b0..1e86635 100644 --- a/include/crucible/ntoa.h +++ b/include/crucible/ntoa.h @@ -7,12 +7,12 @@ namespace crucible { using namespace std; struct bits_ntoa_table { - unsigned long n; - unsigned long mask; + unsigned long long n; + unsigned long long mask; const char *a; }; - string bits_ntoa(unsigned long n, const bits_ntoa_table *a); + string bits_ntoa(unsigned long long n, const bits_ntoa_table *a); }; diff --git a/include/crucible/timequeue.h b/include/crucible/timequeue.h index 2f4349b..6cfcf6f 100644 --- a/include/crucible/timequeue.h +++ b/include/crucible/timequeue.h @@ -23,7 +23,7 @@ namespace crucible { private: struct Item { Timestamp m_time; - unsigned m_id; + unsigned long m_id; Task m_task; bool operator<(const Item &that) const { diff --git a/lib/fs.cc b/lib/fs.cc index 9fceea9..7078fe3 100644 --- a/lib/fs.cc +++ b/lib/fs.cc @@ -834,7 +834,7 @@ namespace crucible { } string - btrfs_search_objectid_ntoa(unsigned objectid) + btrfs_search_objectid_ntoa(uint64_t objectid) { static const bits_ntoa_table table[] = { NTOA_TABLE_ENTRY_ENUM(BTRFS_ROOT_TREE_OBJECTID), diff --git a/lib/ntoa.cc b/lib/ntoa.cc index af3292f..f512d1f 100644 --- a/lib/ntoa.cc +++ b/lib/ntoa.cc @@ -7,7 +7,7 @@ namespace crucible { using namespace std; - string bits_ntoa(unsigned long n, const bits_ntoa_table *table) + string bits_ntoa(unsigned long long n, const bits_ntoa_table *table) { string out; while (n && table->a) { diff --git a/test/limits.cc b/test/limits.cc index 846c9d7..b9f3efc 100644 --- a/test/limits.cc +++ b/test/limits.cc @@ -126,7 +126,13 @@ test_cast_0x80000000_to_things() { auto sv = 0x80000000LL; auto uv = 0x80000000ULL; - SHOULD_PASS(ranged_cast(sv), sv); + if (sizeof(off_t) == 4) { + SHOULD_FAIL(ranged_cast(sv)); + } else if (sizeof(off_t) == 8) { + SHOULD_PASS(ranged_cast(sv), sv); + } else { + assert(!"unhandled case, please add code for off_t here"); + } SHOULD_PASS(ranged_cast(uv), uv); SHOULD_PASS(ranged_cast(uv), uv); SHOULD_FAIL(ranged_cast(uv)); @@ -141,7 +147,13 @@ test_cast_0x80000000_to_things() SHOULD_FAIL(ranged_cast(uv)); SHOULD_FAIL(ranged_cast(uv)); SHOULD_PASS(ranged_cast(sv), sv); - SHOULD_PASS(ranged_cast(sv), sv); + if (sizeof(long) == 4) { + SHOULD_FAIL(ranged_cast(sv)); + } else if (sizeof(long) == 8) { + SHOULD_PASS(ranged_cast(sv), sv); + } else { + assert(!"unhandled case, please add code for long here"); + } SHOULD_FAIL(ranged_cast(sv)); SHOULD_FAIL(ranged_cast(sv)); if (sizeof(int) == 4) { @@ -149,7 +161,7 @@ test_cast_0x80000000_to_things() } else if (sizeof(int) == 8) { SHOULD_PASS(ranged_cast(sv), sv); } else { - assert(!"unhandled case, please add code here"); + assert(!"unhandled case, please add code for int here"); } } @@ -159,7 +171,13 @@ test_cast_0xffffffff_to_things() { auto sv = 0xffffffffLL; auto uv = 0xffffffffULL; - SHOULD_PASS(ranged_cast(sv), sv); + if (sizeof(off_t) == 4) { + SHOULD_FAIL(ranged_cast(sv)); + } else if (sizeof(off_t) == 8) { + SHOULD_PASS(ranged_cast(sv), sv); + } else { + assert(!"unhandled case, please add code for off_t here"); + } SHOULD_PASS(ranged_cast(uv), uv); SHOULD_PASS(ranged_cast(uv), uv); SHOULD_FAIL(ranged_cast(uv)); @@ -174,7 +192,13 @@ test_cast_0xffffffff_to_things() SHOULD_FAIL(ranged_cast(uv)); SHOULD_FAIL(ranged_cast(uv)); SHOULD_PASS(ranged_cast(sv), sv); - SHOULD_PASS(ranged_cast(sv), sv); + if (sizeof(long) == 4) { + SHOULD_FAIL(ranged_cast(sv)); + } else if (sizeof(long) == 8) { + SHOULD_PASS(ranged_cast(sv), sv); + } else { + assert(!"unhandled case, please add code for long here"); + } SHOULD_FAIL(ranged_cast(sv)); SHOULD_FAIL(ranged_cast(sv)); if (sizeof(int) == 4) { @@ -182,7 +206,7 @@ test_cast_0xffffffff_to_things() } else if (sizeof(int) == 8) { SHOULD_PASS(ranged_cast(sv), sv); } else { - assert(!"unhandled case, please add code here"); + assert(!"unhandled case, please add code for int here"); } } @@ -192,7 +216,13 @@ test_cast_0xfffffffff_to_things() { auto sv = 0xfffffffffLL; auto uv = 0xfffffffffULL; - SHOULD_PASS(ranged_cast(sv), sv); + if (sizeof(off_t) == 4) { + SHOULD_FAIL(ranged_cast(sv)); + } else if (sizeof(off_t) == 8) { + SHOULD_PASS(ranged_cast(sv), sv); + } else { + assert(!"unhandled case, please add code for off_t here"); + } SHOULD_PASS(ranged_cast(uv), uv); SHOULD_FAIL(ranged_cast(uv)); SHOULD_FAIL(ranged_cast(uv));