Run clang-format.
This commit is contained in:
@@ -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");
|
fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.rate\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rate > 0) {
|
if (rate > 0) { ret = (double)rate / (double)1000; }
|
||||||
ret = (double)rate/(double)1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(buffer, n, "%.1f", ret);
|
snprintf(buffer, n, "%.1f", ret);
|
||||||
}
|
}
|
||||||
|
@@ -70,13 +70,9 @@ void gradient_factory::setup_masks() {
|
|||||||
mask[2] |= 1 << i;
|
mask[2] |= 1 << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colour_depth % 3 == 1) {
|
if (colour_depth % 3 == 1) { mask[1] |= 1 << (colour_depth / 3); }
|
||||||
mask[1] |= 1 << (colour_depth / 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) { mask[i] = mask[i] << shift[i]; }
|
||||||
mask[i] = mask[i] << shift[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_factory::setup_colour_depth() {
|
void gradient_factory::setup_colour_depth() {
|
||||||
|
@@ -50,7 +50,7 @@ class gradient_factory {
|
|||||||
public:
|
public:
|
||||||
gradient_factory(int width, unsigned long first_colour,
|
gradient_factory(int width, unsigned long first_colour,
|
||||||
unsigned long last_colour);
|
unsigned long last_colour);
|
||||||
virtual ~gradient_factory() { }
|
virtual ~gradient_factory() {}
|
||||||
|
|
||||||
colour_array create_gradient();
|
colour_array create_gradient();
|
||||||
|
|
||||||
|
11
src/linux.cc
11
src/linux.cc
@@ -2353,15 +2353,18 @@ 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) {
|
void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) {
|
||||||
static int reported = 0;
|
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;
|
char *ptr;
|
||||||
long current_now, voltage_now;
|
long current_now, voltage_now;
|
||||||
FILE *current_now_file;
|
FILE *current_now_file;
|
||||||
FILE *voltage_now_file;
|
FILE *voltage_now_file;
|
||||||
double result;
|
double result;
|
||||||
|
|
||||||
snprintf(current_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/current_now", bat);
|
snprintf(current_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/current_now",
|
||||||
snprintf(voltage_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/voltage_now", bat);
|
bat);
|
||||||
|
snprintf(voltage_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/voltage_now",
|
||||||
|
bat);
|
||||||
|
|
||||||
current_now_file = open_file(current_now_path, &reported);
|
current_now_file = open_file(current_now_path, &reported);
|
||||||
voltage_now_file = open_file(voltage_now_path, &reported);
|
voltage_now_file = open_file(voltage_now_path, &reported);
|
||||||
@@ -2373,7 +2376,7 @@ void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) {
|
|||||||
current_now = strtol(current_now_val, &ptr, 10);
|
current_now = strtol(current_now_val, &ptr, 10);
|
||||||
voltage_now = strtol(voltage_now_val, &ptr, 10);
|
voltage_now = strtol(voltage_now_val, &ptr, 10);
|
||||||
|
|
||||||
result = (double)(current_now*voltage_now)/(double)1000000000000;
|
result = (double)(current_now * voltage_now) / (double)1000000000000;
|
||||||
snprintf(buffer, n, "%.1f", result);
|
snprintf(buffer, n, "%.1f", result);
|
||||||
fclose(current_now_file);
|
fclose(current_now_file);
|
||||||
fclose(voltage_now_file);
|
fclose(voltage_now_file);
|
||||||
|
@@ -66,15 +66,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
|
|||||||
|
|
||||||
factory->convert_from_rgb(colour, result);
|
factory->convert_from_rgb(colour, result);
|
||||||
|
|
||||||
SECTION("red") {
|
SECTION("red") { REQUIRE(result[0] == expected_red * full_scale); }
|
||||||
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("green") {
|
|
||||||
REQUIRE(result[1] == expected_green * full_scale);
|
|
||||||
}
|
|
||||||
SECTION("blue") {
|
|
||||||
REQUIRE(result[2] == expected_blue * full_scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete factory;
|
delete factory;
|
||||||
}
|
}
|
||||||
@@ -85,15 +79,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
|
|||||||
|
|
||||||
factory->convert_from_rgb(colour, result);
|
factory->convert_from_rgb(colour, result);
|
||||||
|
|
||||||
SECTION("hue") {
|
SECTION("hue") { REQUIRE(result[0] == expected_hue * 60); }
|
||||||
REQUIRE(result[0] == expected_hue * 60);
|
SECTION("saturation") { REQUIRE(result[1] == expected_saturation); }
|
||||||
}
|
SECTION("value") { REQUIRE(result[2] == expected_value * full_scale); }
|
||||||
SECTION("saturation") {
|
|
||||||
REQUIRE(result[1] == expected_saturation);
|
|
||||||
}
|
|
||||||
SECTION("value") {
|
|
||||||
REQUIRE(result[2] == expected_value * full_scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete factory;
|
delete factory;
|
||||||
}
|
}
|
||||||
@@ -104,15 +92,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
|
|||||||
|
|
||||||
factory->convert_from_rgb(colour, result);
|
factory->convert_from_rgb(colour, result);
|
||||||
|
|
||||||
SECTION("hue") {
|
SECTION("hue") { REQUIRE(result[0] == expected_hue * 60); }
|
||||||
REQUIRE(result[0] == expected_hue * 60);
|
SECTION("chroma") { REQUIRE(result[1] == expected_chroma * full_scale); }
|
||||||
}
|
SECTION("luma") { REQUIRE(result[2] == expected_luma); }
|
||||||
SECTION("chroma") {
|
|
||||||
REQUIRE(result[1] == expected_chroma * full_scale);
|
|
||||||
}
|
|
||||||
SECTION("luma") {
|
|
||||||
REQUIRE(result[2] == expected_luma);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete factory;
|
delete factory;
|
||||||
}
|
}
|
||||||
@@ -121,7 +103,6 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
|
|||||||
TEST_CASE(
|
TEST_CASE(
|
||||||
"gradient_factory should convert to and from rgb "
|
"gradient_factory should convert to and from rgb "
|
||||||
"and get the initial value") {
|
"and get the initial value") {
|
||||||
|
|
||||||
SECTION("rgb_gradient_factory") {
|
SECTION("rgb_gradient_factory") {
|
||||||
long tmp[3];
|
long tmp[3];
|
||||||
auto factory = new conky::rgb_gradient_factory(width, colour, colour);
|
auto factory = new conky::rgb_gradient_factory(width, colour, colour);
|
||||||
|
Reference in New Issue
Block a user