From c52d341f7e2d5fb50f3d4f81bb4f39e9cb118dec Mon Sep 17 00:00:00 2001 From: msweet Date: Tue, 29 Apr 2014 15:57:26 +0000 Subject: [PATCH] Return 0 from all ippGet* functions on error, to match how all other CUPS APIs work. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11840 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.7.txt | 2 ++ cups/ipp.c | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/CHANGES-1.7.txt b/CHANGES-1.7.txt index 272a8087b..71d4c4dbb 100644 --- a/CHANGES-1.7.txt +++ b/CHANGES-1.7.txt @@ -5,6 +5,8 @@ CHANGES IN CUPS V1.7.3 - Fixed mapping of OutputBin values such as "Tray1" () + - Several ippGet* functions incorrectly returned -1 instead of 0 on + error. CHANGES IN CUPS V1.7.2 diff --git a/cups/ipp.c b/cups/ipp.c index debc0e044..024cef863 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -2178,7 +2178,7 @@ ippFirstAttribute(ipp_t *ipp) /* I - IPP message */ * @since CUPS 1.6/OS X 10.8@ */ -int /* O - Boolean value or -1 on error */ +int /* O - Boolean value or 0 on error */ ippGetBoolean(ipp_attribute_t *attr, /* I - IPP attribute */ int element) /* I - Value number (0-based) */ { @@ -2188,7 +2188,7 @@ ippGetBoolean(ipp_attribute_t *attr, /* I - IPP attribute */ if (!attr || attr->value_tag != IPP_TAG_BOOLEAN || element < 0 || element >= attr->num_values) - return (-1); + return (0); /* * Return the value... @@ -2234,7 +2234,7 @@ ippGetCollection( * @since CUPS 1.6/OS X 10.8@ */ -int /* O - Number of values or -1 on error */ +int /* O - Number of values or 0 on error */ ippGetCount(ipp_attribute_t *attr) /* I - IPP attribute */ { /* @@ -2242,7 +2242,7 @@ ippGetCount(ipp_attribute_t *attr) /* I - IPP attribute */ */ if (!attr) - return (-1); + return (0); /* * Return the number of values... @@ -2314,7 +2314,7 @@ ippGetGroupTag(ipp_attribute_t *attr) /* I - IPP attribute */ * @since CUPS 1.6/OS X 10.8@ */ -int /* O - Value or -1 on error */ +int /* O - Value or 0 on error */ ippGetInteger(ipp_attribute_t *attr, /* I - IPP attribute */ int element) /* I - Value number (0-based) */ { @@ -2324,7 +2324,7 @@ ippGetInteger(ipp_attribute_t *attr, /* I - IPP attribute */ if (!attr || (attr->value_tag != IPP_TAG_INTEGER && attr->value_tag != IPP_TAG_ENUM) || element < 0 || element >= attr->num_values) - return (-1); + return (0); /* * Return the value... @@ -2403,7 +2403,7 @@ ippGetOctetString( * @since CUPS 1.6/OS X 10.8@ */ -ipp_op_t /* O - Operation ID or -1 on error */ +ipp_op_t /* O - Operation ID or 0 on error */ ippGetOperation(ipp_t *ipp) /* I - IPP request message */ { /* @@ -2411,7 +2411,7 @@ ippGetOperation(ipp_t *ipp) /* I - IPP request message */ */ if (!ipp) - return ((ipp_op_t)-1); + return ((ipp_op_t)0); /* * Return the value... @@ -2430,7 +2430,7 @@ ippGetOperation(ipp_t *ipp) /* I - IPP request message */ * @since CUPS 1.6/OS X 10.8@ */ -int /* O - Lower value of range or -1 */ +int /* O - Lower value of range or 0 */ ippGetRange(ipp_attribute_t *attr, /* I - IPP attribute */ int element, /* I - Value number (0-based) */ int *uppervalue)/* O - Upper value of range */ @@ -2443,9 +2443,9 @@ ippGetRange(ipp_attribute_t *attr, /* I - IPP attribute */ element < 0 || element >= attr->num_values) { if (uppervalue) - *uppervalue = -1; + *uppervalue = 0; - return (-1); + return (0); } /* @@ -2465,7 +2465,7 @@ ippGetRange(ipp_attribute_t *attr, /* I - IPP attribute */ * @since CUPS 1.6/OS X 10.8@ */ -int /* O - Request ID or -1 on error */ +int /* O - Request ID or 0 on error */ ippGetRequestId(ipp_t *ipp) /* I - IPP message */ { /* @@ -2473,7 +2473,7 @@ ippGetRequestId(ipp_t *ipp) /* I - IPP message */ */ if (!ipp) - return (-1); + return (0); /* * Return the request ID... @@ -2492,7 +2492,7 @@ ippGetRequestId(ipp_t *ipp) /* I - IPP message */ * @since CUPS 1.6/OS X 10.8@ */ -int /* O - Horizontal/cross feed resolution or -1 */ +int /* O - Horizontal/cross feed resolution or 0 */ ippGetResolution( ipp_attribute_t *attr, /* I - IPP attribute */ int element, /* I - Value number (0-based) */ @@ -2505,7 +2505,15 @@ ippGetResolution( if (!attr || attr->value_tag != IPP_TAG_RESOLUTION || element < 0 || element >= attr->num_values) - return (-1); + { + if (yres) + *yres = 0; + + if (units) + *units = (ipp_res_t)0; + + return (0); + } /* * Return the value... @@ -2633,7 +2641,7 @@ ippGetValueTag(ipp_attribute_t *attr) /* I - IPP attribute */ * @since CUPS 1.6/OS X 10.8@ */ -int /* O - Major version number or -1 on error */ +int /* O - Major version number or 0 on error */ ippGetVersion(ipp_t *ipp, /* I - IPP message */ int *minor) /* O - Minor version number or @code NULL@ */ { @@ -2644,9 +2652,9 @@ ippGetVersion(ipp_t *ipp, /* I - IPP message */ if (!ipp) { if (minor) - *minor = -1; + *minor = 0; - return (-1); + return (0); } /* -- 2.39.5