From c3d835ee0963d433c451e6233e88eadc245369b8 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 5 Aug 2016 00:27:00 +0200 Subject: Fix bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/cg-base.c | 22 ++++++++++++++-------- src/cg-base.h | 3 ++- src/cg-negative.c | 12 +++++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/cg-base.c b/src/cg-base.c index 77dfe67..9056e42 100644 --- a/src/cg-base.c +++ b/src/cg-base.c @@ -20,6 +20,8 @@ #include "cg-base.h" +#include + #include #include #include @@ -160,7 +162,10 @@ int make_slaves(void) } qsort(data, n, sizeof(*data), crtc_sort_data_cmp); + if (n == 0) + return 0; + master_i = data[0].index; for (i = 1; i < n; i++) if (memcmp(data + i, data + master, sizeof(*data) - sizeof(data->index))) { @@ -169,8 +174,8 @@ int make_slaves(void) crtc_updates[master_i].slaves = calloc(i - master, sizeof(size_t)); if (crtc_updates[master_i].slaves == NULL) return -1; - for (j = 0; master + j < i; j++) - crtc_updates[master_i].slaves[j] = data[master + j].index; + for (j = 1; master + j < i; j++) + crtc_updates[master_i].slaves[j - 1] = data[master + j].index; } master = i; master_i = data[master].index; @@ -187,8 +192,8 @@ int make_slaves(void) crtc_updates[master_i].slaves = calloc(i - master, sizeof(size_t)); if (crtc_updates[master_i].slaves == NULL) return -1; - for (j = 0; master + j < i; j++) - crtc_updates[master_i].slaves[j] = data[master + j].index; + for (j = 1; master + j < i; j++) + crtc_updates[master_i].slaves[j - 1] = data[master + j].index; } return 0; @@ -570,7 +575,7 @@ int main(int argc, char* argv[]) int at_end; opt[1] = *args++; arg = args + 1; - if ((at_end = !*arg)) + if ((at_end = !*args)) arg = argv[1]; if (!strcmp(opt, "-M")) { @@ -603,7 +608,7 @@ int main(int argc, char* argv[]) switch (handle_opt(opt, arg)) { case 0: - goto next_arg; + goto next_opt; case 1: break; default: @@ -611,9 +616,9 @@ int main(int argc, char* argv[]) } argv += at_end; argc -= at_end; - goto next_arg; + break; + next_opt:; } - next_arg:; } crtcs_n = crtcs_i; @@ -756,6 +761,7 @@ int main(int argc, char* argv[]) #define X(CONST, MEMBER, MAX, TYPE)\ case CONST:\ libcoopgamma_ramps_initialise(&(crtc_updates[crtcs_i].filter.ramps.MEMBER));\ + libclut_start_over(&(crtc_updates[crtcs_i].filter.ramps.MEMBER), MAX, TYPE, 1, 1, 1);\ break; LIST_DEPTHS #undef X diff --git a/src/cg-base.h b/src/cg-base.h index 848a202..269f2a3 100644 --- a/src/cg-base.h +++ b/src/cg-base.h @@ -51,7 +51,8 @@ typedef struct filter_update * `.filter.crtc`, `.filter.class`, and * `.filter.priority`, `.filter.depth` * are preconfigured, and `.filter.ramps` - * is preinitialised. + * is preinitialised and preset to an + * identity ramp */ libcoopgamma_filter_t filter; diff --git a/src/cg-negative.c b/src/cg-negative.c index 566b81a..b0c19ed 100644 --- a/src/cg-negative.c +++ b/src/cg-negative.c @@ -30,7 +30,7 @@ /** * The default filter priority for the program */ -const int64_t default_priority = ((int64_t)1) << 62; +const int64_t default_priority = ((int64_t)1) << 63; /** * The default class for the program @@ -151,13 +151,13 @@ int handle_opt(char* opt, char* arg) int handle_args(int argc, char* argv[], char* method, char* site, char** crtcs, char* prio, char* rule) { - int q = dflag + (xflag | rplus | gplus | bplus); + int q = xflag + (dflag | rplus | gplus | bplus); q += (method != NULL) && !strcmp(method, "?"); q += (prio != NULL) && !strcmp(prio, "?"); - q += (rule != NULL) && (!strcmp(method, "?") || !strcmp(method, "??")); + q += (rule != NULL) && (!strcmp(rule, "?") || !strcmp(rule, "??")); for (; *crtcs; crtcs++) q += !strcmp(*crtcs, "?"); - if (argc || q || (dflag && (prio != NULL))) + if (argc || (q > 1) || (xflag && (prio != NULL))) usage(); } @@ -229,12 +229,14 @@ int start(void) } while (r != 1) - if ((r = update_filter(i, -1)) < 0) + if ((r = synchronise(-1)) < 0) return r; if (!dflag) return 0; + if (libcoopgamma_set_nonblocking(&cg, 0) < 0) + return -1; for (;;) if (libcoopgamma_synchronise(&cg, NULL, 0, &j) < 0) switch (errno) -- cgit v1.2.3-70-g09d2