From 12f1eb15ca3fed6310402847559a7c99d3c77847 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 2 Apr 2022 17:14:10 -0400 Subject: Programmatically apply new formatting to code Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done --- libtests/rc4.cc | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'libtests/rc4.cc') diff --git a/libtests/rc4.cc b/libtests/rc4.cc index b7aecd4b..7245ef86 100644 --- a/libtests/rc4.cc +++ b/libtests/rc4.cc @@ -1,12 +1,12 @@ #include #include -#include #include +#include -#include -#include #include +#include #include +#include #ifdef NDEBUG // We need assert even in a release build for test code. @@ -14,7 +14,8 @@ #endif #include -static void other_tests() +static void +other_tests() { // Test cases not covered by the pipeline: string as key, convert // in place @@ -26,16 +27,15 @@ static void other_tests() std::cout << "passed" << std::endl; } -int main(int argc, char* argv[]) +int +main(int argc, char* argv[]) { - if ((argc == 2) && (strcmp(argv[1], "other") == 0)) - { + if ((argc == 2) && (strcmp(argv[1], "other") == 0)) { other_tests(); return 0; } - if (argc != 4) - { + if (argc != 4) { std::cerr << "Usage: rc4 hex-key infile outfile" << std::endl; exit(2); } @@ -49,35 +49,30 @@ int main(int argc, char* argv[]) key[keylen] = '\0'; FILE* infile = QUtil::safe_fopen(infilename, "rb"); - for (unsigned int i = 0; i < strlen(hexkey); i += 2) - { + for (unsigned int i = 0; i < strlen(hexkey); i += 2) { char t[3]; t[0] = hexkey[i]; t[1] = hexkey[i + 1]; t[2] = '\0'; long val = strtol(t, 0, 16); - key[i/2] = static_cast(val); + key[i / 2] = static_cast(val); } FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); // Use a small buffer size (64) for testing Pl_RC4* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U); - delete [] key; + delete[] key; // 64 < buffer size < 512, buffer_size is not a power of 2 for testing unsigned char buf[100]; bool done = false; - while (! done) - { + while (!done) { size_t len = fread(buf, 1, sizeof(buf), infile); - if (len <= 0) - { + if (len <= 0) { done = true; - } - else - { + } else { rc4->write(buf, len); } } -- cgit v1.2.3-70-g09d2