]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Refactor MIME locking.
authorMichael R Sweet <msweet@msweet.org>
Sun, 16 Nov 2025 23:15:11 +0000 (18:15 -0500)
committerMichael R Sweet <msweet@msweet.org>
Sun, 16 Nov 2025 23:15:11 +0000 (18:15 -0500)
scheduler/client.c
scheduler/conf.c
scheduler/conf.h
scheduler/filter.c
scheduler/ipp.c
scheduler/job.c
scheduler/mime.h
scheduler/printers.c
scheduler/type.c

index dd98c6b445c06ef45532a4bc8b71af3d4e05cbe1..dbb82c293c2a94e9f02b0a92180d9324d0dd5a91 100644 (file)
@@ -1043,11 +1043,11 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
 
             if ((filename = get_file(con, &filestats, buf, sizeof(buf))) != NULL)
             {
-             cupsRWLockRead(&MimeDatabase->lock);
+             cupsRWLockRead(&MimeLock);
 
              type = mimeFileType(MimeDatabase, filename, NULL, NULL);
 
-             cupsRWUnlock(&MimeDatabase->lock);
+             cupsRWUnlock(&MimeLock);
 
               cupsdLogClient(con, CUPSD_LOG_DEBUG, "filename=\"%s\", type=%s/%s", filename, type ? type->super : "", type ? type->type : "");
 
index da5fd54a2fa1cffd83a7c91c00508046d33a43a3..387c02a6c8b296dbdc125bcecc3ea8a6beeac07b 100644 (file)
@@ -1585,11 +1585,6 @@ cupsdReadConfiguration(void)
       !old_serverroot || !ServerRoot || strcmp(old_serverroot, ServerRoot) ||
       !old_requestroot || !RequestRoot || strcmp(old_requestroot, RequestRoot))
   {
-    mime_type_t        *type;                  /* Current type */
-    char       mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE];
-                                       /* MIME type name */
-
-
     cupsdLogMessage(CUPSD_LOG_INFO, "Full reload is required.");
 
    /*
@@ -1605,14 +1600,6 @@ cupsdReadConfiguration(void)
     if (MimeDatabase != NULL)
       mimeDelete(MimeDatabase);
 
-    if (NumMimeTypes)
-    {
-      for (i = 0; i < NumMimeTypes; i ++)
-       _cupsStrFree(MimeTypes[i]);
-
-      free(MimeTypes);
-    }
-
    /*
     * Read the MIME type and conversion database...
     */
@@ -1622,79 +1609,32 @@ cupsdReadConfiguration(void)
 
     MimeDatabase = mimeNew();
     mimeSetErrorCallback(MimeDatabase, mime_error_cb, NULL);
-    cupsRWInit(&MimeDatabase->lock);
 
-    cupsRWLockWrite(&MimeDatabase->lock);
-    MimeDatabase = mimeLoadTypes(MimeDatabase, mimedir);
-    MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot);
-    MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp);
-    MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp);
-    cupsRWUnlock(&MimeDatabase->lock);
+    mimeAddType(MimeDatabase, "application", "octet-stream");
+    mimeLoadTypes(MimeDatabase, mimedir);
+    mimeLoadTypes(MimeDatabase, ServerRoot);
+    mimeLoadFilters(MimeDatabase, mimedir, temp);
+    mimeLoadFilters(MimeDatabase, ServerRoot, temp);
 
-    if (!MimeDatabase)
+    if (mimeNumTypes(MimeDatabase) == 1 || mimeNumFilters(MimeDatabase) == 0)
     {
-      cupsdLogMessage(CUPSD_LOG_EMERG,
-                      "Unable to load MIME database from \"%s\" or \"%s\".",
-                     mimedir, ServerRoot);
+      cupsdLogMessage(CUPSD_LOG_EMERG, "Unable to load MIME database from \"%s\" or \"%s\".", mimedir, ServerRoot);
       if (FatalErrors & CUPSD_FATAL_CONFIG)
         return (0);
     }
 
-    cupsdLogMessage(CUPSD_LOG_INFO,
-                    "Loaded MIME database from \"%s\" and \"%s\": %d types, "
-                   "%d filters...", mimedir, ServerRoot,
-                   mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase));
-
-   /*
-    * Create a list of MIME types for the document-format-supported
-    * attribute...
-    */
-
-    NumMimeTypes = mimeNumTypes(MimeDatabase);
-    if (!mimeType(MimeDatabase, "application", "octet-stream"))
-      NumMimeTypes ++;
-
-    if ((MimeTypes = calloc((size_t)NumMimeTypes, sizeof(const char *))) == NULL)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Unable to allocate memory for %d MIME types.",
-                     NumMimeTypes);
-      NumMimeTypes = 0;
-    }
-    else
-    {
-      for (i = 0, type = mimeFirstType(MimeDatabase);
-          type;
-          i ++, type = mimeNextType(MimeDatabase))
-      {
-       snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
-
-       MimeTypes[i] = _cupsStrAlloc(mimetype);
-      }
-
-      if (i < NumMimeTypes)
-       MimeTypes[i] = _cupsStrAlloc("application/octet-stream");
-    }
+    cupsdLogMessage(CUPSD_LOG_INFO, "Loaded MIME database from \"%s\" and \"%s\": %d types, %d filters.", mimedir, ServerRoot, mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase));
 
     if (LogLevel == CUPSD_LOG_DEBUG2)
     {
+      mime_type_t      *type;          /* Current type */
       mime_filter_t    *filter;        /* Current filter */
 
+      for (type = mimeFirstType(MimeDatabase); type; type = mimeNextType(MimeDatabase))
+       cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: type %s/%s", type->super, type->type);
 
-      for (type = mimeFirstType(MimeDatabase);
-           type;
-          type = mimeNextType(MimeDatabase))
-       cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: type %s/%s",
-                       type->super, type->type);
-
-      for (filter = mimeFirstFilter(MimeDatabase);
-           filter;
-          filter = mimeNextFilter(MimeDatabase))
-       cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                       "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
-                       filter->src->super, filter->src->type,
-                       filter->dst->super, filter->dst->type,
-                       filter->cost, filter->filter);
+      for (filter = mimeFirstFilter(MimeDatabase); filter; filter = mimeNextFilter(MimeDatabase))
+       cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s", filter->src->super, filter->src->type, filter->dst->super, filter->dst->type, filter->cost, filter->filter);
     }
 
    /*
index e3458f260749c51691637f9f93f0f19dc39d30e2..94f3a8545a79aacb7ee68d08ae810b11f8d01caa 100644 (file)
@@ -234,10 +234,8 @@ VAR char           *PageLogFormat          VALUE(NULL);
                                        /* Page log format */
 VAR mime_t             *MimeDatabase           VALUE(NULL);
                                        /* MIME type database */
-VAR int                        NumMimeTypes            VALUE(0);
-                                       /* Number of MIME types */
-VAR const char         **MimeTypes             VALUE(NULL);
-                                       /* Array of MIME types */
+VAR cups_rwlock_t      MimeLock                VALUE(CUPS_RWLOCK_INITIALIZER);
+                                       // Read/write lock for MIME type database
 
 VAR int                        CreateSelfSignedCerts   VALUE(TRUE);
                                        /* Automatically create self-signed certs? */
index b00680006fe8c5e3a5bc9539febac4fc045634d2..c8cb2c593166646bfa0131568da61e32ca597f51 100644 (file)
@@ -86,11 +86,9 @@ mimeAddFilter(mime_t      *mime,     // I - MIME database
     {
       c->dst = dst;
 
-      cupsRWLockWrite(&mime->lock);
       if (!mime->ftypes)
         mime->ftypes = cupsArrayNew3((cups_array_cb_t)mime_compare_ftypess, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, (cups_afree_cb_t)mime_free_ftypes);
       cupsArrayAdd(mime->ftypes, c);
-      cupsRWUnlock(&mime->lock);
     }
   }
 
@@ -360,9 +358,7 @@ mime_find_ftypes(mime_t      *mime, // I - MIME database
   // Lookup the destination type in the array...
   key.dst = dst;
 
-  cupsRWLockRead(&mime->lock);
   match = (mime_ftypes_t *)cupsArrayFind(mime->ftypes, &key);
-  cupsRWUnlock(&mime->lock);
 
   return (match);
 }
index 0b016f31e61198fe3488257ba68a6b5ca9327c03..4ac89cdf41bbe4146ded3676c52e382cdc567d20 100644 (file)
@@ -8587,7 +8587,7 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
     cupsCopyString(type, "octet-stream", sizeof(type));
   }
 
-  cupsRWLockRead(&MimeDatabase->lock);
+  cupsRWLockRead(&MimeLock);
 
   if (!strcmp(super, "application") && !strcmp(type, "octet-stream"))
   {
@@ -8613,7 +8613,7 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
   else
     filetype = mimeType(MimeDatabase, super, type);
 
-  cupsRWUnlock(&MimeDatabase->lock);
+  cupsRWUnlock(&MimeLock);
 
   if (filetype &&
       (!format ||
@@ -9804,7 +9804,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     cupsCopyString(type, "octet-stream", sizeof(type));
   }
 
-  cupsRWLockRead(&MimeDatabase->lock);
+  cupsRWLockRead(&MimeLock);
 
   if (!strcmp(super, "application") && !strcmp(type, "octet-stream"))
   {
@@ -9835,7 +9835,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
   else
     filetype = mimeType(MimeDatabase, super, type);
 
-  cupsRWUnlock(&MimeDatabase->lock);
+  cupsRWUnlock(&MimeLock);
 
   if (filetype)
   {
@@ -11381,7 +11381,7 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
       return;
     }
 
-    cupsRWLockRead(&MimeDatabase->lock);
+    cupsRWLockRead(&MimeLock);
 
     if ((strcmp(super, "application") || strcmp(type, "octet-stream")) &&
        !mimeType(MimeDatabase, super, type))
@@ -11393,12 +11393,12 @@ validate_job(cupsd_client_t  *con,    /* I - Client connection */
       ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
                    "document-format", NULL, format->values[0].string.text);
 
-      cupsRWUnlock(&MimeDatabase->lock);
+      cupsRWUnlock(&MimeLock);
 
       return;
     }
 
-    cupsRWUnlock(&MimeDatabase->lock);
+    cupsRWUnlock(&MimeLock);
   }
 
  /*
index 047e5dfc9494842c0ccdf6ad26df221c593cfb5c..7eff88bf5427e6464fa4030d5aadc738d53c38f7 100644 (file)
@@ -577,7 +577,7 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
     if (stat(filename, &fileinfo))
       fileinfo.st_size = 0;
 
-    cupsRWLockWrite(&MimeDatabase->lock);
+    cupsRWLockWrite(&MimeLock);
 
     if (job->print_as_raster)
     {
@@ -614,7 +614,7 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
 
       ippSetString(job->attrs, &job->reasons, 0, "document-unprintable-error");
 
-      cupsRWUnlock(&MimeDatabase->lock);
+      cupsRWUnlock(&MimeLock);
 
       goto abort_job;
     }
@@ -703,7 +703,7 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
       filters = prefilters;
     }
 
-    cupsRWUnlock(&MimeDatabase->lock);
+    cupsRWUnlock(&MimeLock);
   }
 
  /*
@@ -1919,7 +1919,7 @@ cupsdLoadJob(cupsd_job_t *job)            /* I - Job */
     * Find all the d##### files...
     */
 
-    cupsRWLockRead(&MimeDatabase->lock);
+    cupsRWLockRead(&MimeLock);
 
     for (fileid = 1; fileid < 10000; fileid ++)
     {
@@ -1973,7 +1973,7 @@ cupsdLoadJob(cupsd_job_t *job)            /* I - Job */
 
          job->num_files = 0;
 
-         cupsRWUnlock(&MimeDatabase->lock);
+         cupsRWUnlock(&MimeLock);
 
          return (0);
        }
@@ -1989,7 +1989,7 @@ cupsdLoadJob(cupsd_job_t *job)            /* I - Job */
                                              "vnd.cups-raw");
     }
 
-    cupsRWUnlock(&MimeDatabase->lock);
+    cupsRWUnlock(&MimeLock);
   }
 
  /*
@@ -4545,7 +4545,7 @@ load_job_cache(const char *filename)      /* I - job.cache filename */
 
       number --;
 
-      cupsRWLockRead(&MimeDatabase->lock);
+      cupsRWLockRead(&MimeLock);
 
       job->compressions[number] = compression;
       job->filetypes[number]    = mimeType(MimeDatabase, super, type);
@@ -4574,7 +4574,7 @@ load_job_cache(const char *filename)      /* I - job.cache filename */
                                            "vnd.cups-raw");
       }
 
-      cupsRWUnlock(&MimeDatabase->lock);
+      cupsRWUnlock(&MimeLock);
     }
     else
       cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown %s directive on line %d of %s.", line, linenum, filename);
index 916b4c8d9922e2143454256fb4c137b264c0a507..d853621a66234926a34ce9e4c7a5a53fe05a4879 100644 (file)
@@ -14,7 +14,6 @@
 #  include <cups/array.h>
 #  include <cups/ipp.h>
 #  include <cups/file.h>
-#  include <cups/thread.h>
 #  include <regex.h>
 #  ifdef __cplusplus
 extern "C" {
@@ -110,7 +109,6 @@ typedef struct _mime_s                      // MIME Database
   cups_array_t         *ftypes;        // Filter types
   mime_error_cb_t      error_cb;       // Error message callback
   void                 *error_ctx;     // Pointer for callback
-  cups_rwlock_t                lock;           // Read/write lock for guarding data for background updates
 } mime_t;
 
 
index 2055b648b255d58c8dbbea7005094a669ee3d79e..d97d5c2c5ec75607be6001b3e788113e9fa6c3c8 100644 (file)
@@ -94,11 +94,11 @@ cupsdAddPrinter(const char *name)   /* I - Name of printer */
   p->accepting   = 0;
   p->shared      = DefaultShared;
 
-  cupsRWLockWrite(&MimeDatabase->lock);
+  cupsRWLockWrite(&MimeLock);
 
-  p->filetype    = mimeAddType(MimeDatabase, "printer", name);
+  p->filetype = mimeAddType(MimeDatabase, "printer", name);
 
-  cupsRWUnlock(&MimeDatabase->lock);
+  cupsRWUnlock(&MimeLock);
 
   cupsdSetString(&p->job_sheets[0], "none");
   cupsdSetString(&p->job_sheets[1], "none");
@@ -732,7 +732,7 @@ cupsdDeletePrinter(
   if (p->printers != NULL)
     free(p->printers);
 
-  cupsRWLockWrite(&MimeDatabase->lock);
+  cupsRWLockWrite(&MimeLock);
 
   delete_printer_filters(p);
 
@@ -747,7 +747,7 @@ cupsdDeletePrinter(
   mimeDeleteType(MimeDatabase, p->filetype);
   mimeDeleteType(MimeDatabase, p->prefiltertype);
 
-  cupsRWUnlock(&MimeDatabase->lock);
+  cupsRWUnlock(&MimeLock);
 
   cupsdFreeStrings(&(p->users));
   cupsdFreeQuotas(p);
@@ -1397,7 +1397,7 @@ cupsdRenamePrinter(
   * Rename the printer type...
   */
 
-  cupsRWLockWrite(&MimeDatabase->lock);
+  cupsRWLockWrite(&MimeLock);
 
   mimeDeleteType(MimeDatabase, p->filetype);
   p->filetype = mimeAddType(MimeDatabase, "printer", name);
@@ -1408,7 +1408,7 @@ cupsdRenamePrinter(
     p->prefiltertype = mimeAddType(MimeDatabase, "prefilter", name);
   }
 
-  cupsRWUnlock(&MimeDatabase->lock);
+  cupsRWUnlock(&MimeLock);
 
  /*
   * Rename the printer...
@@ -2227,13 +2227,14 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
     cupsdCreateCommonData();
 
   cupsRWLockWrite(&p->lock);
-  cupsRWLockWrite(&MimeDatabase->lock);
 
  /*
   * Clear out old filters, if any...
   */
 
+  cupsRWLockWrite(&MimeLock);
   delete_printer_filters(p);
+  cupsRWUnlock(&MimeLock);
 
  /*
   * Figure out the authentication that is required for the printer.
@@ -2404,14 +2405,12 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
     * Add filters for printer...
     */
 
-    cupsdSetPrinterReasons(p, "-cups-missing-filter-warning,"
-                             "cups-insecure-filter-warning");
+    cupsRWLockWrite(&MimeLock);
+    cupsdSetPrinterReasons(p, "-cups-missing-filter-warning,cups-insecure-filter-warning");
 
     if (p->pc && p->pc->filters)
     {
-      for (filter = (char *)cupsArrayFirst(p->pc->filters);
-          filter;
-          filter = (char *)cupsArrayNext(p->pc->filters))
+      for (filter = (char *)cupsArrayFirst(p->pc->filters); filter; filter = (char *)cupsArrayNext(p->pc->filters))
        add_printer_filter(p, p->filetype, filter);
     }
     else if (!(p->type & CUPS_PTYPE_REMOTE))
@@ -2427,8 +2426,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
       * Add a PostScript filter, since this is still possibly PS printer.
       */
 
-      add_printer_filter(p, p->filetype,
-                        "application/vnd.cups-postscript 0 -");
+      add_printer_filter(p, p->filetype, "application/vnd.cups-postscript 0 -");
     }
 
     if (p->pc && p->pc->prefilters)
@@ -2436,13 +2434,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
       if (!p->prefiltertype)
        p->prefiltertype = mimeAddType(MimeDatabase, "prefilter", p->name);
 
-      for (filter = (char *)cupsArrayFirst(p->pc->prefilters);
-          filter;
-          filter = (char *)cupsArrayNext(p->pc->prefilters))
+      for (filter = (char *)cupsArrayFirst(p->pc->prefilters); filter; filter = (char *)cupsArrayNext(p->pc->prefilters))
        add_printer_filter(p, p->prefiltertype, filter);
     }
   }
 
+  cupsRWUnlock(&MimeLock);
+
  /*
   * Copy marker attributes as needed...
   */
@@ -2546,9 +2544,9 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
   * Populate the document-format-supported attribute...
   */
 
+  cupsRWLockWrite(&MimeLock);
   add_printer_formats(p);
-
-  cupsRWUnlock(&MimeDatabase->lock);
+  cupsRWUnlock(&MimeLock);
 
  /*
   * Add name-default attributes...
@@ -3483,18 +3481,14 @@ add_printer_filter(
   * Add the filter to the MIME database, supporting wildcards as needed...
   */
 
-  for (temptype = mimeFirstType(MimeDatabase);
-       temptype;
-       temptype = mimeNextType(MimeDatabase))
-    if (((super[0] == '*' && _cups_strcasecmp(temptype->super, "printer")) ||
-         !_cups_strcasecmp(temptype->super, super)) &&
-        (type[0] == '*' || !_cups_strcasecmp(temptype->type, type)))
+  for (temptype = mimeFirstType(MimeDatabase); temptype; temptype = mimeNextType(MimeDatabase))
+  {
+    if (((super[0] == '*' && _cups_strcasecmp(temptype->super, "printer")) || !_cups_strcasecmp(temptype->super, super)) && (type[0] == '*' || !_cups_strcasecmp(temptype->type, type)))
     {
       if (desttype != filtertype)
       {
         cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_filter: Adding filter %s/%s %s/%s %d %s", temptype->super, temptype->type, desttype->super, desttype->type, cost, program);
-        filterptr = mimeAddFilter(MimeDatabase, temptype, desttype, cost,
-                                 program);
+        filterptr = mimeAddFilter(MimeDatabase, temptype, desttype, cost, program);
 
         if (!mimeFilterLookup(MimeDatabase, desttype, filtertype))
         {
@@ -3505,13 +3499,13 @@ add_printer_filter(
       else
       {
         cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_filter: Adding filter %s/%s %s/%s %d %s", temptype->super, temptype->type, filtertype->super, filtertype->type, cost, program);
-        filterptr = mimeAddFilter(MimeDatabase, temptype, filtertype, cost,
-                                 program);
+        filterptr = mimeAddFilter(MimeDatabase, temptype, filtertype, cost, program);
       }
 
       if (filterptr)
        filterptr->maxsize = maxsize;
     }
+  }
 }
 
 
@@ -3542,7 +3536,7 @@ add_printer_formats(cupsd_printer_t *p)   /* I - Printer */
 
   if (p->raw)
   {
-    ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_MIMETYPE), "document-format-supported", NumMimeTypes, NULL, MimeTypes);
+    ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_MIMETYPE), "document-format-supported", NULL, "application/octet-stream");
     return;
   }
 
@@ -3561,25 +3555,13 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */
   * Add the file formats that can be filtered...
   */
 
-  if ((type = mimeType(MimeDatabase, "application", "octet-stream")) == NULL ||
-      !cupsArrayFind(p->filetypes, type))
-    i = 1;
-  else
-    i = 0;
-
-  cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: %d supported types", cupsArrayCount(p->filetypes) + i);
+  cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: %d supported types", cupsArrayCount(p->filetypes) + 1);
 
-  attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE,
-                       "document-format-supported",
-                       cupsArrayCount(p->filetypes) + i, NULL, NULL);
+  attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, "document-format-supported", cupsArrayCount(p->filetypes) + 1, NULL, NULL);
+  attr->values[0].string.text = _cupsStrAlloc("application/octet-stream");
+  cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[0]='application/octet-stream'");
 
-  if (i)
-  {
-    attr->values[0].string.text = _cupsStrAlloc("application/octet-stream");
-    cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[0]='application/octet-stream'");
-  }
-
-  for (type = (mime_type_t *)cupsArrayFirst(p->filetypes); type; i ++, type = (mime_type_t *)cupsArrayNext(p->filetypes))
+  for (i = 1, type = (mime_type_t *)cupsArrayFirst(p->filetypes); type; i ++, type = (mime_type_t *)cupsArrayNext(p->filetypes))
   {
     snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
 
@@ -3667,9 +3649,8 @@ delete_printer_filters(
   * type == printer...
   */
 
-  for (filter = mimeFirstFilter(MimeDatabase);
-       filter;
-       filter = mimeNextFilter(MimeDatabase))
+  for (filter = mimeFirstFilter(MimeDatabase); filter; filter = mimeNextFilter(MimeDatabase))
+  {
     if (filter->dst == p->filetype || filter->dst == p->prefiltertype ||
         cupsArrayFind(p->dest_types, filter->dst))
     {
@@ -3679,17 +3660,15 @@ delete_printer_filters(
 
       mimeDeleteFilter(MimeDatabase, filter);
     }
+  }
 
-  for (type = (mime_type_t *)cupsArrayFirst(p->dest_types);
-       type;
-       type = (mime_type_t *)cupsArrayNext(p->dest_types))
+  for (type = (mime_type_t *)cupsArrayFirst(p->dest_types); type; type = (mime_type_t *)cupsArrayNext(p->dest_types))
     mimeDeleteType(MimeDatabase, type);
 
   cupsArrayDelete(p->dest_types);
   p->dest_types = NULL;
 
-  cupsdSetPrinterReasons(p, "-cups-insecure-filter-warning"
-                            ",cups-missing-filter-warning");
+  cupsdSetPrinterReasons(p, "-cups-insecure-filter-warning,cups-missing-filter-warning");
 }
 
 
index c3fdb5b28c68161823de5f1ede4064fc73a2abeb..2851f6218170d3f310cea4227208ef4c9fd3a0a1 100644 (file)
@@ -710,6 +710,8 @@ void
 _mimeFreeType(mime_type_t *t,          // I - File type
               void        *data)       // I - Callback data (not used)
 {
+  (void)data;
+
   mime_delete_rules(t->rules);
   free(t);
 }