summaryrefslogtreecommitdiff
path: root/Tests/Kernel
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2023-03-01 00:11:43 +0330
committerAndreas Kling <kling@serenityos.org>2023-03-01 10:47:19 +0100
commit500044906d1b90f1c8b1a2f5675a2f82ab92b758 (patch)
tree7d6aae259b188c1b6879c591eebdfd7f55d9b71c /Tests/Kernel
parent60908adcbe2afd611233957bb3126f736eb18e25 (diff)
downloadserenity-500044906d1b90f1c8b1a2f5675a2f82ab92b758.zip
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in StringViews and might have a non-properly-null-terminated string as a value. As a bonus, using StringView (and DeprecatedString where necessary) leads to nicer looking code too :^)
Diffstat (limited to 'Tests/Kernel')
-rw-r--r--Tests/Kernel/stress-truncate.cpp8
-rw-r--r--Tests/Kernel/stress-writeread.cpp4
2 files changed, 6 insertions, 6 deletions
diff --git a/Tests/Kernel/stress-truncate.cpp b/Tests/Kernel/stress-truncate.cpp
index 684a697124..1e066155c5 100644
--- a/Tests/Kernel/stress-truncate.cpp
+++ b/Tests/Kernel/stress-truncate.cpp
@@ -18,7 +18,7 @@ int main(int argc, char** argv)
for (auto i = 0; i < argc; ++i)
arguments.append({ argv[i], strlen(argv[i]) });
- char const* target = nullptr;
+ DeprecatedString target;
int max_file_size = 1024 * 1024;
int count = 1024;
@@ -28,7 +28,7 @@ int main(int argc, char** argv)
args_parser.add_positional_argument(target, "Target file path", "target");
args_parser.parse(arguments);
- int fd = creat(target, 0666);
+ int fd = creat(target.characters(), 0666);
if (fd < 0) {
perror("Couldn't create target file");
return EXIT_FAILURE;
@@ -38,13 +38,13 @@ int main(int argc, char** argv)
for (int i = 0; i < count; i++) {
auto new_file_size = AK::get_random<uint64_t>() % (max_file_size + 1);
printf("(%d/%d)\tTruncating to %" PRIu64 " bytes...\n", i + 1, count, new_file_size);
- if (truncate(target, new_file_size) < 0) {
+ if (truncate(target.characters(), new_file_size) < 0) {
perror("Couldn't truncate target file");
return EXIT_FAILURE;
}
}
- if (unlink(target) < 0) {
+ if (unlink(target.characters()) < 0) {
perror("Couldn't remove target file");
return EXIT_FAILURE;
}
diff --git a/Tests/Kernel/stress-writeread.cpp b/Tests/Kernel/stress-writeread.cpp
index 48c5a52a19..352cdb16af 100644
--- a/Tests/Kernel/stress-writeread.cpp
+++ b/Tests/Kernel/stress-writeread.cpp
@@ -65,7 +65,7 @@ int main(int argc, char** argv)
for (auto i = 0; i < argc; ++i)
arguments.append({ argv[i], strlen(argv[i]) });
- char const* target = nullptr;
+ DeprecatedString target;
int min_block_offset = 0;
int block_length = 2048;
int block_size = 512;
@@ -96,7 +96,7 @@ int main(int argc, char** argv)
}
auto buffer = buffer_result.release_value();
- int fd = open(target, O_CREAT | O_RDWR, 0666);
+ int fd = open(target.characters(), O_CREAT | O_RDWR, 0666);
if (fd < 0) {
perror("Couldn't create target file");
return EXIT_FAILURE;