summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2019-09-07 13:04:14 -0600
committerAaron Ball <nullspoon@oper.io>2019-09-07 13:04:14 -0600
commit5503c140dac2f22eee2a620703aff57f28b4512b (patch)
tree0e29f7f169b0acf6119bafc35faafb97567c4512
parentf9415b4976b31ce6c6f68ee6776194af90bcf05b (diff)
downloadkbd-fade-master.tar.gz
kbd-fade-master.tar.xz
Fix invalid wait valuesHEADmaster
Previously, bad wait values default to 0 (like `sdf`) because atoi returns 0 when it doesn't understand the input. This caused very rapid color changing. Now we check if wait is set to less than 1, assuming an error, and defaults to 1000. This accounts for when users pass negative values and strings. Also removed unused `highest` variable.
-rw-r--r--src/main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 79a7933..700b966 100644
--- a/src/main.c
+++ b/src/main.c
@@ -107,7 +107,6 @@ void channel_fade(int* a, int* b) {
*/
void rgb_fade(int r, int g, int b, int wait) {
int i = 0;
- int highest = 0;
int colors[3] = {r, g, b};
int size = 3;
@@ -133,6 +132,11 @@ int main(int argc, char* argv[]) {
if(argc == 2)
wait = atoi(argv[1]);
+ if(wait < 1) {
+ printf("Error setting wait. Defaulting to 1000\n");
+ wait=1000;
+ }
+
load_current_state(&r, &g, &b);
rgb_fade(r, g, b, wait);
}

Generated by cgit