From 72288f3069862775ba9ff40d650f3ae9aad45751 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 7 Oct 2019 15:12:22 -0400 Subject: [PATCH] Fix compiler warnings from new clang - lots of enums being assigned to ints but the compiler deciding that was worthy of a warning (even though the range of values clearly falls within the range of an int...) --- backend/ipp.c | 4 ++-- cups/ppd-cache.c | 6 +++--- filter/rastertohp.c | 2 +- scheduler/ipp.c | 14 +++++++------- scheduler/job.c | 2 +- scheduler/printers.c | 2 +- scheduler/subscriptions.c | 4 ++-- test/ippfind.c | 4 ++-- test/ippserver.c | 4 ++-- test/ipptool.c | 6 +++--- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/backend/ipp.c b/backend/ipp.c index 23a46a7675..482d6f766e 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -2572,7 +2572,7 @@ monitor_printer( } fprintf(stderr, "DEBUG: (monitor) job-state = %s\n", - ippEnumString("job-state", monitor->job_state)); + ippEnumString("job-state", (int)monitor->job_state)); if (!job_canceled && (monitor->job_state == IPP_JSTATE_CANCELED || @@ -2654,7 +2654,7 @@ monitor_printer( ippDelete(response); fprintf(stderr, "DEBUG: (monitor) job-state = %s\n", - ippEnumString("job-state", monitor->job_state)); + ippEnumString("job-state", (int)monitor->job_state)); if (!job_canceled && (monitor->job_state == IPP_JSTATE_CANCELED || diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index b1b53e4b30..02e502f8fb 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -2089,7 +2089,7 @@ _ppdCacheGetFinishingValues( f; f = (_pwg_finishings_t *)cupsArrayNext(pc->finishings)) { - DEBUG_printf(("_ppdCacheGetFinishingValues: Checking %d (%s)", f->value, ippEnumString("finishings", f->value))); + DEBUG_printf(("_ppdCacheGetFinishingValues: Checking %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value))); for (i = f->num_options, option = f->options; i > 0; i --, option ++) { @@ -2105,9 +2105,9 @@ _ppdCacheGetFinishingValues( if (i == 0) { - DEBUG_printf(("_ppdCacheGetFinishingValues: Adding %d (%s)", f->value, ippEnumString("finishings", f->value))); + DEBUG_printf(("_ppdCacheGetFinishingValues: Adding %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value))); - values[num_values ++] = f->value; + values[num_values ++] = (int)f->value; if (num_values >= max_values) break; diff --git a/filter/rastertohp.c b/filter/rastertohp.c index eb11c8c1f8..d231bdca3f 100644 --- a/filter/rastertohp.c +++ b/filter/rastertohp.c @@ -111,7 +111,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ * Setup printer/job attributes... */ - Duplex = header->Duplex; + Duplex = (int)header->Duplex; ColorBits = header->cupsBitsPerColor; if ((!Duplex || (Page & 1)) && header->MediaPosition) diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 9be8a7f3b6..07765a15b4 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1918,7 +1918,7 @@ add_job(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", - job->state_value); + (int)job->state_value); ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_TEXT, "job-state-message", NULL, ""); ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, job->reasons->values[0].string.text); @@ -3284,7 +3284,7 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ * Cancel all jobs on all printers... */ - cupsdCancelJobs(NULL, username, purge); + cupsdCancelJobs(NULL, username, (int)purge); cupsdLogMessage(CUPSD_LOG_INFO, "All jobs were %s by \"%s\".", purge == CUPSD_JOB_PURGE ? "purged" : "canceled", @@ -3343,7 +3343,7 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ * Cancel all of the jobs on the named printer... */ - cupsdCancelJobs(printer->name, username, purge); + cupsdCancelJobs(printer->name, username, (int)purge); cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \"%s\" were %s by \"%s\".", printer->name, @@ -4000,7 +4000,7 @@ close_job(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", - job->state_value); + (int)job->state_value); con->response->request.status.status_code = IPP_OK; @@ -4995,7 +4995,7 @@ copy_printer_attrs( if (!ra || cupsArrayFind(ra, "printer-state")) ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", - printer->state); + (int)printer->state); if (!ra || cupsArrayFind(ra, "printer-state-change-date-time")) ippAddDate(con->response, IPP_TAG_PRINTER, "printer-state-change-date-time", ippTimeToDate(printer->state_time)); @@ -5541,7 +5541,7 @@ create_local_printer( add_printer_attributes: ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", (char)printer->accepting); - ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", printer->state); + ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", (int)printer->state); add_printer_state_reasons(con, printer); httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), httpIsEncrypted(con->http) ? "ipps" : "ipp", NULL, con->clientname, con->clientport, "/printers/%s", printer->name); @@ -9971,7 +9971,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", jobid); ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", - job->state_value); + (int)job->state_value); ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, job->reasons->values[0].string.text); diff --git a/scheduler/job.c b/scheduler/job.c index 1a7a34ca9f..7c87e76e20 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -2581,7 +2581,7 @@ cupsdSetJobState( job->state_value = newstate; if (job->state) - job->state->values[0].integer = newstate; + job->state->values[0].integer = (int)newstate; switch (newstate) { diff --git a/scheduler/printers.c b/scheduler/printers.c index 937d0f3c9d..9c1e186008 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -4523,7 +4523,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ for (fin = (_pwg_finishings_t *)cupsArrayFirst(p->pc->finishings); fin; fin = (_pwg_finishings_t *)cupsArrayNext(p->pc->finishings)) { if (num_finishings < (int)(sizeof(finishings) / sizeof(finishings[0]))) - finishings[num_finishings++] = fin->value; + finishings[num_finishings++] = (int)fin->value; switch (fin->value) { diff --git a/scheduler/subscriptions.c b/scheduler/subscriptions.c index cac340520d..4bdd1f00ed 100644 --- a/scheduler/subscriptions.c +++ b/scheduler/subscriptions.c @@ -174,7 +174,7 @@ cupsdAddEvent( "printer-name", NULL, dest->name); ippAddInteger(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_ENUM, - "printer-state", dest->state); + "printer-state", (int)dest->state); if (dest->num_reasons == 0) ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, @@ -199,7 +199,7 @@ cupsdAddEvent( ippAddInteger(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_INTEGER, "notify-job-id", job->id); ippAddInteger(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_ENUM, - "job-state", job->state_value); + "job-state", (int)job->state_value); if ((attr = ippFindAttribute(job->attrs, "job-name", IPP_TAG_NAME)) != NULL) diff --git a/test/ippfind.c b/test/ippfind.c index 012609d96b..a63aba0a79 100644 --- a/test/ippfind.c +++ b/test/ippfind.c @@ -1798,7 +1798,7 @@ eval_expr(ippfind_srv_t *service, /* I - Service */ */ if (expressions && expressions->parent) - logic = expressions->parent->op; + logic = (int)expressions->parent->op; else logic = IPPFIND_OP_AND; @@ -2370,7 +2370,7 @@ list_service(ippfind_srv_t *service) /* I - Service */ httpClose(http); _cupsLangPrintf(stdout, "%s %s %s %s", service->uri, - ippEnumString("printer-state", pstate), + ippEnumString("printer-state", (int)pstate), paccepting ? "accepting-jobs" : "not-accepting-jobs", preasons); } diff --git a/test/ippserver.c b/test/ippserver.c index 7d83158a22..b58c8507a6 100644 --- a/test/ippserver.c +++ b/test/ippserver.c @@ -834,7 +834,7 @@ copy_job_attributes( if (!ra || cupsArrayFind(ra, "job-state")) ippAddInteger(client->response, IPP_TAG_JOB, IPP_TAG_ENUM, - "job-state", job->state); + "job-state", (int)job->state); if (!ra || cupsArrayFind(ra, "job-state-message")) { @@ -3647,7 +3647,7 @@ ipp_get_printer_attributes( if (!ra || cupsArrayFind(ra, "printer-state")) ippAddInteger(client->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, - "printer-state", printer->state); + "printer-state", (int)printer->state); if (!ra || cupsArrayFind(ra, "printer-state-change-date-time")) ippAddDate(client->response, IPP_TAG_PRINTER, "printer-state-change-date-time", ippTimeToDate(printer->state_time)); diff --git a/test/ipptool.c b/test/ipptool.c index 703e6810ec..750128fd2a 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -2619,7 +2619,7 @@ do_tests(cups_file_t *outfile, /* I - Output file */ group = attrptr ? attrptr->group_tag : IPP_TAG_ZERO; attrptr; attrptr = attrptr->next) - print_attr(outfile, Output, attrptr, &group); + print_attr(outfile, (int)Output, attrptr, &group); cupsFilePuts(outfile, "\n"); } cupsFilePuts(outfile, "\n"); @@ -3388,7 +3388,7 @@ do_tests(cups_file_t *outfile, /* I - Output file */ group = attrptr ? attrptr->group_tag : IPP_TAG_ZERO; attrptr; attrptr = attrptr->next) - print_attr(outfile, Output, attrptr, &group); + print_attr(outfile, (int)Output, attrptr, &group); cupsFilePuts(outfile, "\n"); cupsFilePuts(outfile, "\n"); } @@ -3494,7 +3494,7 @@ do_tests(cups_file_t *outfile, /* I - Output file */ { if (!strcmp(displayed[i], attrptr->name)) { - print_attr(outfile, Output, attrptr, NULL); + print_attr(outfile, (int)Output, attrptr, NULL); break; } } -- 2.47.2