diff --git a/src/common.cc b/src/common.cc index 3b3da656..410d300f 100644 --- a/src/common.cc +++ b/src/common.cc @@ -640,7 +640,7 @@ void print_battery_time(struct text_object *obj, char *p, } void battery_power_draw(struct text_object *obj, char *p, - unsigned int p_max_size) { + unsigned int p_max_size) { get_battery_power_draw(p, p_max_size, obj->data.s); } diff --git a/src/freebsd.cc b/src/freebsd.cc index e5dddbdb..89bc60f0 100644 --- a/src/freebsd.cc +++ b/src/freebsd.cc @@ -474,9 +474,7 @@ void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) { fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.rate\"\n"); } - if (rate > 0) { - ret = (double)rate/(double)1000; - } + if (rate > 0) { ret = (double)rate / (double)1000; } snprintf(buffer, n, "%.1f", ret); } diff --git a/src/gradient.cc b/src/gradient.cc index 77d9a09e..af06fdc3 100644 --- a/src/gradient.cc +++ b/src/gradient.cc @@ -70,18 +70,14 @@ void gradient_factory::setup_masks() { mask[2] |= 1 << i; } - if (colour_depth % 3 == 1) { - mask[1] |= 1 << (colour_depth / 3); - } + if (colour_depth % 3 == 1) { mask[1] |= 1 << (colour_depth / 3); } - for (int i = 0; i < 3; i++) { - mask[i] = mask[i] << shift[i]; - } + for (int i = 0; i < 3; i++) { mask[i] = mask[i] << shift[i]; } } void gradient_factory::setup_colour_depth() { #ifdef BUILD_X11 - if (state == nullptr) { // testing purposes + if (state == nullptr) { // testing purposes colour_depth = 24; } else if (out_to_x.get(*state)) { colour_depth = DisplayPlanes(display, screen); diff --git a/src/gradient.h b/src/gradient.h index b46db9a6..ebec330d 100644 --- a/src/gradient.h +++ b/src/gradient.h @@ -50,7 +50,7 @@ class gradient_factory { public: gradient_factory(int width, unsigned long first_colour, unsigned long last_colour); - virtual ~gradient_factory() { } + virtual ~gradient_factory() {} colour_array create_gradient(); diff --git a/src/linux.cc b/src/linux.cc index 27ed293b..14b93148 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -2353,30 +2353,33 @@ void get_battery_short_status(char *buffer, unsigned int n, const char *bat) { void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) { static int reported = 0; - char current_now_path[256], voltage_now_path[256], current_now_val[256], voltage_now_val[256]; + char current_now_path[256], voltage_now_path[256], current_now_val[256], + voltage_now_val[256]; char *ptr; long current_now, voltage_now; FILE *current_now_file; FILE *voltage_now_file; double result; - snprintf(current_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/current_now", bat); - snprintf(voltage_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/voltage_now", bat); + snprintf(current_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/current_now", + bat); + snprintf(voltage_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/voltage_now", + bat); current_now_file = open_file(current_now_path, &reported); voltage_now_file = open_file(voltage_now_path, &reported); if (current_now_file != nullptr && voltage_now_file != nullptr) { - fgets(current_now_val, 256, current_now_file); - fgets(voltage_now_val, 256, voltage_now_file); + fgets(current_now_val, 256, current_now_file); + fgets(voltage_now_val, 256, voltage_now_file); - current_now = strtol(current_now_val, &ptr, 10); - voltage_now = strtol(voltage_now_val, &ptr, 10); + current_now = strtol(current_now_val, &ptr, 10); + voltage_now = strtol(voltage_now_val, &ptr, 10); - result = (double)(current_now*voltage_now)/(double)1000000000000; - snprintf(buffer, n, "%.1f", result); - fclose(current_now_file); - fclose(voltage_now_file); + result = (double)(current_now * voltage_now) / (double)1000000000000; + snprintf(buffer, n, "%.1f", result); + fclose(current_now_file); + fclose(voltage_now_file); } } diff --git a/tests/test-gradient.cc b/tests/test-gradient.cc index de52fed9..269e0ef6 100644 --- a/tests/test-gradient.cc +++ b/tests/test-gradient.cc @@ -32,21 +32,21 @@ #include const int width = 4; -#ifdef BUILD_X11 // 24-bit color depth -const long colour = 0x996633; // brown +#ifdef BUILD_X11 // 24-bit color depth +const long colour = 0x996633; // brown const long expected_hue = 256; -const long expected_value = 0x99; // max(0x99, 0x66, 0x33) -const long expected_chroma = 0x66; // (0x99 - 0x33) +const long expected_value = 0x99; // max(0x99, 0x66, 0x33) +const long expected_chroma = 0x66; // (0x99 - 0x33) const long expected_luma = 20712665L; const long expected_saturation = 122880L; const long expected_red = 0x99; const long expected_green = 0x66; const long expected_blue = 0x33; -#else // 16-bit color depth -const long colour = 0x99A6; // brown +#else // 16-bit color depth +const long colour = 0x99A6; // brown const long expected_hue = 275; -const long expected_value = 0x13; // max(0x13, 0x0d, 0x06) -const long expected_chroma = 0x0d; // (0x1a - 0x06) +const long expected_value = 0x13; // max(0x13, 0x0d, 0x06) +const long expected_chroma = 0x0d; // (0x1a - 0x06) const long expected_luma = 2610173L; const long expected_saturation = 126113L; const long expected_red = 0x13; @@ -66,15 +66,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") { factory->convert_from_rgb(colour, result); - SECTION("red") { - REQUIRE(result[0] == expected_red * full_scale); - } - SECTION("green") { - REQUIRE(result[1] == expected_green * full_scale); - } - SECTION("blue") { - REQUIRE(result[2] == expected_blue * full_scale); - } + SECTION("red") { REQUIRE(result[0] == expected_red * full_scale); } + SECTION("green") { REQUIRE(result[1] == expected_green * full_scale); } + SECTION("blue") { REQUIRE(result[2] == expected_blue * full_scale); } delete factory; } @@ -85,15 +79,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") { factory->convert_from_rgb(colour, result); - SECTION("hue") { - REQUIRE(result[0] == expected_hue * 60); - } - SECTION("saturation") { - REQUIRE(result[1] == expected_saturation); - } - SECTION("value") { - REQUIRE(result[2] == expected_value * full_scale); - } + SECTION("hue") { REQUIRE(result[0] == expected_hue * 60); } + SECTION("saturation") { REQUIRE(result[1] == expected_saturation); } + SECTION("value") { REQUIRE(result[2] == expected_value * full_scale); } delete factory; } @@ -104,15 +92,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") { factory->convert_from_rgb(colour, result); - SECTION("hue") { - REQUIRE(result[0] == expected_hue * 60); - } - SECTION("chroma") { - REQUIRE(result[1] == expected_chroma * full_scale); - } - SECTION("luma") { - REQUIRE(result[2] == expected_luma); - } + SECTION("hue") { REQUIRE(result[0] == expected_hue * 60); } + SECTION("chroma") { REQUIRE(result[1] == expected_chroma * full_scale); } + SECTION("luma") { REQUIRE(result[2] == expected_luma); } delete factory; } @@ -121,7 +103,6 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") { TEST_CASE( "gradient_factory should convert to and from rgb " "and get the initial value") { - SECTION("rgb_gradient_factory") { long tmp[3]; auto factory = new conky::rgb_gradient_factory(width, colour, colour); @@ -129,7 +110,7 @@ TEST_CASE( auto result = factory->convert_to_rgb(tmp); REQUIRE(result == colour); - + delete factory; } @@ -145,7 +126,7 @@ TEST_CASE( auto result = factory->convert_to_rgb(tmp); REQUIRE(result == colour); - + delete factory; } @@ -156,7 +137,7 @@ TEST_CASE( auto result = factory->convert_to_rgb(tmp); REQUIRE(result == colour); - + delete factory; } #endif