From 0a8b8c29d48b9c1e92e96a77234f5500d20c1bef Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 1 Dec 2016 14:24:39 +0100 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 | 4 ++-- src/cg-brilliance.c | 6 +++--- src/cg-icc.c | 27 +++++++++------------------ 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/cg-base.c b/src/cg-base.c index d75e70d..a8c7f71 100644 --- a/src/cg-base.c +++ b/src/cg-base.c @@ -811,7 +811,7 @@ LIST_DEPTHS const char* crtc = crtc_updates[crtcs_i].filter.crtc; if (cg.error.custom) { - if ((cg.error.number != 0) || (cg.error.description != NULL)) + if ((cg.error.number != 0) && (cg.error.description != NULL)) fprintf(stderr, "%s: %s-side error number %" PRIu64 " for CRTC %s: %s\n", argv0, side, cg.error.number, crtc, cg.error.description); else if (cg.error.number != 0) @@ -866,7 +866,7 @@ LIST_DEPTHS const char* side = cg.error.server_side ? "server" : "client"; if (cg.error.custom) { - if ((cg.error.number != 0) || (cg.error.description != NULL)) + if ((cg.error.number != 0) && (cg.error.description != NULL)) fprintf(stderr, "%s: %s-side error number %" PRIu64 ": %s\n", argv0, side, cg.error.number, cg.error.description); else if (cg.error.number != 0) diff --git a/src/cg-brilliance.c b/src/cg-brilliance.c index 0d5c930..1ad590d 100644 --- a/src/cg-brilliance.c +++ b/src/cg-brilliance.c @@ -149,9 +149,9 @@ static int parse_double(double* restrict out, const char* restrict str) */ int handle_args(int argc, char* argv[], char* prio) { - char* red; - char* green; - char* blue; + char* red = NULL; + char* green = NULL; + char* blue = NULL; int q = xflag + dflag; if ((q > 1) || (xflag && (prio != NULL || argc))) usage(); diff --git a/src/cg-icc.c b/src/cg-icc.c index 5e56acf..31ac50c 100644 --- a/src/cg-icc.c +++ b/src/cg-icc.c @@ -279,20 +279,10 @@ static int load_icc_table(int fd, const char *dirname) } if (ferror(fp)) goto fail; - if (!ptr) - { - crtc_icc_keys = calloc(1, sizeof(*crtc_icc_keys)); - if (crtc_icc_keys == NULL) - goto fail; - } - crtc_icc_keys[ptr] = NULL; - if (!ptr) - { - crtc_icc_values = calloc(1, sizeof(*crtc_icc_values)); - if (crtc_icc_values == NULL) - goto fail; - } - crtc_icc_values[ptr] = NULL; + if (crtc_icc_keys != NULL) + crtc_icc_keys[ptr] = NULL; + if (crtc_icc_values != NULL) + crtc_icc_values[ptr] = NULL; fclose(fp); free(line); return 0; @@ -328,7 +318,7 @@ int handle_args(int argc, char* argv[], char* prio) usage(); icc_pathname = *argv; memset(&uniramps, 0, sizeof(uniramps)); - if (icc_pathname == NULL) + if (!xflag && (icc_pathname == NULL)) { pw = getpwuid(getuid()); if ((pw == NULL) || (pw->pw_dir == NULL)) @@ -763,9 +753,10 @@ static int load_icc(const char* file, libcoopgamma_ramps_t* ramps, libcoopgamma_ static const char* get_icc(const char* crtc) { size_t i; - for (i = 0; crtc_icc_keys[i] != NULL; i++) - if (!strcasecmp(crtc, crtc_icc_keys[i])) - return crtc_icc_values[i]; + if (crtc_icc_keys != NULL) + for (i = 0; crtc_icc_keys[i] != NULL; i++) + if (!strcasecmp(crtc, crtc_icc_keys[i])) + return crtc_icc_values[i]; return NULL; } -- cgit v1.2.3-70-g09d2