Skip to content

Commit f6e51f8

Browse files
committed
explicitly state which wrong value was provided
1 parent 9d8cc5e commit f6e51f8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/musl/mmap.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,22 @@ static void* __sys_mmap(/*const*/ uintptr_t addr, const size_t length, const os:
7676

7777
// TODO(mazunki): this is unnecessary when ::Sharing becomes a real type
7878
if (util::has_flag(flags, Sharing::Private) == util::has_flag(flags, Sharing::Shared)) {
79-
Expects(false && "sys_mmap: mapping must be either Private xor Shared");
79+
Expectsf(false, "sys_mmap: mapping must be either Private xor Shared");
8080
return mmap_failed(EINVAL);
8181
}
8282

8383
if (length == 0) {
84-
Expects(false && "Mapping must never allocate 0 bytes");
84+
Expectsf(false, "Mapping must never allocate 0 bytes");
8585
return mmap_failed(EINVAL);
8686
}
8787

8888
if (util::has_flag(Flags::Anonymous)) {
8989
if (file_descriptor) {
90-
Expects(false && "Anonymous mappings must set fd=-1"); // TODO(mazunki): rename -1 when signature changes
90+
Expectsf(false, "Anonymous mappings must set fd=-1, got fd={}", file_descriptor.value()); // TODO(mazunki): rename -1 when signature changes
9191
return mmap_failed(EINVAL);
9292
}
9393
if (offset != 0) {
94-
Expects(false && "Anonymous mappings should have offset=0");
94+
Expectsf(false, "Anonymous mappings should have offset=0, got offset={}", offset);
9595
return mmap_failed(EINVAL);
9696
}
9797
}
@@ -108,12 +108,12 @@ static void* __sys_mmap(/*const*/ uintptr_t addr, const size_t length, const os:
108108
// https://pubs.opengroup.org/onlinepubs/009695399/functions/mmap.html
109109

110110
if (file_descriptor) {
111-
Expects(false && "Mapping to file descriptor is not yet implemented");
111+
Expectsf(false, "Mapping to file descriptor is not yet implemented, got fd={}", file_descriptor.value());
112112
return mmap_failed(ENOTSUP);
113113
}
114114

115115
if (util::missing_flag(flags, Sharing::Anonymous)) {
116-
Expects(false && "Support for non-MAP_ANONYMOUS mappings is not yet implemented");
116+
Expectsf(false, "Support for non-MAP_ANONYMOUS mappings is not yet implemented");
117117
return mmap_failed(ENOTSUP);
118118
}
119119

@@ -131,16 +131,16 @@ static void* __sys_mmap(/*const*/ uintptr_t addr, const size_t length, const os:
131131
const bool do_override = util::has_flag(flags, Flags::FixedOverride) ? true : false;
132132

133133
return mmap_failed(ENOTSUP);
134-
// res = kalloc_fixed(reinterpret_cast<void*>(addr), len_rounded, /*permit_override=*/true);
134+
// res = kalloc_fixed(reinterpret_cast<void*>(addr), len_rounded, do_override);
135135

136136
} else {
137137
if (util::has_flag(flags, Flags::Private)) {
138138
if (util::missing_flag(flags, Flags::Anonymous)) {
139-
Expects(false && "Support for MAP_PRIVATE other than with MAP_ANONYMOUS is not yet implemented");
139+
Expectsf(false, "Support for MAP_PRIVATE other than with MAP_ANONYMOUS is not yet implemented");
140140
return mmap_failed(ENOTSUP);
141141
}
142142
if (addr != 0) {
143-
Expects(false && "Support for MAP_PRIVATE other than for new allocations (addr=0) is not yet implemented");
143+
Expectsf(false, "Support for MAP_PRIVATE other than for new allocations (addr=0) is not yet implemented. Got addr={}", addr);
144144
return mmap_failed(ENOTSUP);
145145
}
146146
}

0 commit comments

Comments
 (0)