From 59521fb102edd5186474495c05986368829080af Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 7 Mar 2013 22:03:22 +0000 Subject: [PATCH] Fix some clang-reported issues. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10884 7a7537e8-13f0-0310-91df-b6672ffda945 --- backend/usb-darwin.c | 8 ++++---- scheduler/ipp.c | 8 ++++++-- scheduler/job.c | 23 ++++++++++++++--------- scheduler/testlpd.c | 12 ++++++------ 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c index fe8daeb2e7..9a93f123cb 100644 --- a/backend/usb-darwin.c +++ b/backend/usb-darwin.c @@ -1,7 +1,7 @@ /* * "$Id$" * -* Copyright 2005-2012 Apple Inc. All rights reserved. +* Copyright 2005-2013 Apple Inc. All rights reserved. * * IMPORTANT: This Apple software is supplied to you by Apple Computer, * Inc. ("Apple") in consideration of your agreement to the following @@ -1132,7 +1132,7 @@ static void iterate_printers(iterator_callback_t callBack, CFRelease(usb_klass); CFRelease(usb_subklass); - kr = IOServiceAddMatchingNotification(addNotification, kIOMatchedNotification, usbPrinterMatchDictionary, &device_added, &reference, &addIterator); + IOServiceAddMatchingNotification(addNotification, kIOMatchedNotification, usbPrinterMatchDictionary, &device_added, &reference, &addIterator); if (addIterator != 0x0) { device_added (&reference, addIterator); @@ -1171,7 +1171,7 @@ static void device_added(void *userdata, /* One last call to the call back now that we are not longer have printers left to iterate... */ - if (reference->keepRunning) + if (reference->keepRunning && reference->callback) reference->keepRunning = reference->callback(reference->userdata, 0x0); if (!reference->keepRunning) @@ -1719,7 +1719,7 @@ static void copy_devicestring(io_service_t usbInterface, kr = load_classdriver(NULL, interface, &klassDriver); if (kr == kIOReturnSuccess && klassDriver != NULL) - kr = copy_deviceid(klassDriver, deviceID); + copy_deviceid(klassDriver, deviceID); unload_classdriver(&klassDriver); diff --git a/scheduler/ipp.c b/scheduler/ipp.c index de76ab3d52..09295e4bc4 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1235,6 +1235,12 @@ add_file(cupsd_client_t *con, /* I - Connection to client */ sizeof(mime_type_t *)); } + if (compressions) + job->compressions = compressions; + + if (filetypes) + job->filetypes = filetypes; + if (!compressions || !filetypes) { cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE, @@ -1247,9 +1253,7 @@ add_file(cupsd_client_t *con, /* I - Connection to client */ return (-1); } - job->compressions = compressions; job->compressions[job->num_files] = compression; - job->filetypes = filetypes; job->filetypes[job->num_files] = filetype; job->num_files ++; diff --git a/scheduler/job.c b/scheduler/job.c index 1d43f1c22d..ffe72a56ef 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1869,6 +1869,12 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ fileid); } + if (compressions) + job->compressions = compressions; + + if (filetypes) + job->filetypes = filetypes; + if (!compressions || !filetypes) { cupsdLogMessage(CUPSD_LOG_ERROR, @@ -1878,12 +1884,6 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ ippDelete(job->attrs); job->attrs = NULL; - if (compressions) - free(compressions); - - if (filetypes) - free(filetypes); - if (job->compressions) { free(job->compressions); @@ -1900,9 +1900,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ return (0); } - job->compressions = compressions; - job->filetypes = filetypes; - job->num_files = fileid; + job->num_files = fileid; } job->filetypes[fileid - 1] = mimeFileType(MimeDatabase, jobfile, NULL, @@ -4160,6 +4158,13 @@ load_job_cache(const char *filename) /* I - job.cache filename */ line, linenum); } + if (job) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "Missing directive on line %d.", linenum); + cupsdDeleteJob(job, CUPSD_JOB_PURGE); + } + cupsFileClose(fp); } diff --git a/scheduler/testlpd.c b/scheduler/testlpd.c index bc90757a98..60076939e5 100644 --- a/scheduler/testlpd.c +++ b/scheduler/testlpd.c @@ -3,7 +3,7 @@ * * cups-lpd test program for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -42,11 +42,11 @@ */ static int do_command(int outfd, int infd, const char *command); -static int print_job(int outfd, int infd, char *dest, char **args); +static int print_job(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4))); static int print_waiting(int outfd, int infd, char *dest); -static int remove_job(int outfd, int infd, char *dest, char **args); -static int status_long(int outfd, int infd, char *dest, char **args); -static int status_short(int outfd, int infd, char *dest, char **args); +static int remove_job(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4))); +static int status_long(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4))); +static int status_short(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4))); static void usage(void) __attribute__((noreturn)); @@ -76,7 +76,7 @@ main(int argc, /* I - Number of command-line arguments */ */ op = NULL; - opargs = NULL; + opargs = argv + argc; dest = NULL; cupslpd_argc = 1; cupslpd_argv[0] = (char *)"cups-lpd"; -- 2.47.2