/*
- * "$Id: debug.c 4027 2012-11-16 01:00:05Z msweet $"
+ * "$Id: debug.c 11558 2014-02-06 18:33:34Z msweet $"
*
- * Debugging functions for CUPS.
+ * Debugging functions for CUPS.
*
- * Copyright 2008-2012 by Apple Inc.
+ * Copyright 2008-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * debug_vsnprintf() - Format a string into a fixed size buffer.
- * _cups_debug_printf() - Write a formatted line to the log.
- * _cups_debug_puts() - Write a single line to the log.
- * _cups_debug_set() - Enable or disable debug logging.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* 'debug_vsnprintf()' - Format a string into a fixed size buffer.
*/
-static int /* O - Number of bytes formatted */
+static ssize_t /* O - Number of bytes formatted */
debug_vsnprintf(char *buffer, /* O - Output buffer */
size_t bufsize, /* O - Size of output buffer */
const char *format, /* I - printf-style format string */
*tptr, /* Pointer into temporary format */
temp[1024]; /* Buffer for formatted numbers */
char *s; /* Pointer to string */
- int bytes; /* Total number of bytes needed */
+ ssize_t bytes; /* Total number of bytes needed */
if (!buffer || bufsize < 2 || !format)
format ++;
width = va_arg(ap, int);
- snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", width);
+ snprintf(tptr, sizeof(tformat) - (size_t)(tptr - tformat), "%d", width);
tptr += strlen(tptr);
}
else
format ++;
prec = va_arg(ap, int);
- snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", prec);
+ snprintf(tptr, sizeof(tformat) - (size_t)(tptr - tformat), "%d", prec);
tptr += strlen(tptr);
}
else
case 'e' :
case 'f' :
case 'g' :
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
sprintf(temp, tformat, va_arg(ap, double));
case 'o' :
case 'u' :
case 'x' :
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
# ifdef HAVE_LONG_LONG
break;
case 'p' : /* Pointer value */
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
sprintf(temp, tformat, va_arg(ap, void *));
if (bufptr)
{
if (width <= 1)
- *bufptr++ = va_arg(ap, int);
+ *bufptr++ = (char)va_arg(ap, int);
else
{
if ((bufptr + width) > bufend)
break;
case 'n' : /* Output number of chars so far */
- *(va_arg(ap, int *)) = bytes;
+ *(va_arg(ap, int *)) = (int)bytes;
break;
}
}
va_list ap; /* Pointer to arguments */
struct timeval curtime; /* Current time */
char buffer[2048]; /* Output buffer */
- size_t bytes; /* Number of bytes in buffer */
+ ssize_t bytes; /* Number of bytes in buffer */
int level; /* Log level in message */
bytes = debug_vsnprintf(buffer + 19, sizeof(buffer) - 20, format, ap) + 19;
va_end(ap);
- if (bytes >= (sizeof(buffer) - 1))
+ if ((size_t)bytes >= (sizeof(buffer) - 1))
{
buffer[sizeof(buffer) - 2] = '\n';
bytes = sizeof(buffer) - 1;
*/
_cupsMutexLock(&debug_log_mutex);
- write(_cups_debug_fd, buffer, bytes);
+ write(_cups_debug_fd, buffer, (size_t)bytes);
_cupsMutexUnlock(&debug_log_mutex);
}
{
struct timeval curtime; /* Current time */
char buffer[2048]; /* Output buffer */
- size_t bytes; /* Number of bytes in buffer */
+ ssize_t bytes; /* Number of bytes in buffer */
int level; /* Log level in message */
(int)(curtime.tv_sec % 60), (int)(curtime.tv_usec / 1000),
s);
- if (bytes >= (sizeof(buffer) - 1))
+ if ((size_t)bytes >= (sizeof(buffer) - 1))
{
buffer[sizeof(buffer) - 2] = '\n';
bytes = sizeof(buffer) - 1;
*/
_cupsMutexLock(&debug_log_mutex);
- write(_cups_debug_fd, buffer, bytes);
+ write(_cups_debug_fd, buffer, (size_t)bytes);
_cupsMutexUnlock(&debug_log_mutex);
}
/*
- * End of "$Id: debug.c 4027 2012-11-16 01:00:05Z msweet $".
+ * End of "$Id: debug.c 11558 2014-02-06 18:33:34Z msweet $".
*/