Print this page
12399 kobj printf functions should be checked

@@ -303,12 +303,12 @@
  * Common printf function pointer. Can handle only one conversion
  * specification in the format string. Some of the functions invoked
  * through this function pointer cannot handle more that one conversion
  * specification in the format string.
  */
-void (*_kobj_printf)(void *, const char *, ...);        /* printf routine */
-void (*_vkobj_printf)(void *, const char *, va_list);   /* vprintf routine */
+void (*_kobj_printf)(void *, const char *, ...) __KPRINTFLIKE(2);
+void (*_vkobj_printf)(void *, const char *, va_list) __KVPRINTFLIKE(2);
 
 /*
  * Standalone function pointers for use within krtld.
  * Many platforms implement optimized platmod versions of
  * utilities such as bcopy and any such are not yet available

@@ -509,11 +509,11 @@
         kobj_sync_instruction_memory(s_text, e_text - s_text);
 
 #ifdef  KOBJ_DEBUG
         if (kobj_debug & D_DEBUG)
                 _kobj_printf(ops,
-                    "krtld: transferring control to: 0x%p\n", entry);
+                    "krtld: transferring control to: 0x%lx\n", entry);
 #endif
 
         /*
          * Make sure the mod system knows about the modules already loaded.
          */

@@ -530,11 +530,11 @@
         standalone = 0;
 
 #ifdef  KOBJ_DEBUG
         if (kobj_debug & D_DEBUG)
                 _kobj_printf(ops,
-                    "krtld: really transferring control to: 0x%p\n", entry);
+                    "krtld: really transferring control to: 0x%lx\n", entry);
 #endif
 
         /* restore printf/bcopy/bzero vectors before returning */
         kobj_restore_vectors();
 

@@ -855,13 +855,13 @@
 
 #ifdef  KOBJ_DEBUG
         if (kobj_debug & D_LOADING) {
                 _kobj_printf(ops, "krtld: file=%s\n", mp->filename);
                 _kobj_printf(ops, "\ttext: 0x%p", mp->text);
-                _kobj_printf(ops, " size: 0x%x\n", mp->text_size);
+                _kobj_printf(ops, " size: 0x%lx\n", mp->text_size);
                 _kobj_printf(ops, "\tdata: 0x%p", mp->data);
-                _kobj_printf(ops, " dsize: 0x%x\n", mp->data_size);
+                _kobj_printf(ops, " dsize: 0x%lx\n", mp->data_size);
         }
 #endif /* KOBJ_DEBUG */
 
         /*
          * Insert symbols into the hash table.

@@ -966,13 +966,13 @@
 
 #ifdef  KOBJ_DEBUG
         if (kobj_debug & D_LOADING) {
                 _kobj_printf(ops, "krtld: file=%s\n", mp->filename);
                 _kobj_printf(ops, "\ttext:0x%p", mp->text);
-                _kobj_printf(ops, " size: 0x%x\n", mp->text_size);
+                _kobj_printf(ops, " size: 0x%lx\n", mp->text_size);
                 _kobj_printf(ops, "\tdata:0x%p", mp->data);
-                _kobj_printf(ops, " dsize: 0x%x\n", mp->data_size);
+                _kobj_printf(ops, " dsize: 0x%lx\n", mp->data_size);
         }
 #endif /* KOBJ_DEBUG */
 
         /*
          * Insert the symbols into the hash table.

@@ -2008,13 +2008,13 @@
 
 #ifdef  KOBJ_DEBUG
         if (kobj_debug & D_LOADING) {
                 _kobj_printf(ops, "krtld: file=%s\n", mp->filename);
                 _kobj_printf(ops, "\ttext:0x%p", mp->text);
-                _kobj_printf(ops, " size: 0x%x\n", mp->text_size);
+                _kobj_printf(ops, " size: 0x%lx\n", mp->text_size);
                 _kobj_printf(ops, "\tdata:0x%p", mp->data);
-                _kobj_printf(ops, " dsize: 0x%x\n", mp->data_size);
+                _kobj_printf(ops, " dsize: 0x%lx\n", mp->data_size);
         }
 #endif /* KOBJ_DEBUG */
 
         /*
          * For primary kernel modules, we defer

@@ -2712,12 +2712,12 @@
                         continue;
 #ifdef  KOBJ_DEBUG
                 if (kobj_debug & D_DEBUG)
                         _kobj_printf(ops,
                             "krtld: crypto_es_hash: updating hash with"
-                            " %s data size=%d\n", shstrtab + shp->sh_name,
-                            shp->sh_size);
+                            " %s data size=%lx\n", shstrtab + shp->sh_name,
+                            (size_t)shp->sh_size);
 #endif
                 ASSERT(shp->sh_addr != 0);
                 SHA1Update(&ctx, (const uint8_t *)shp->sh_addr, shp->sh_size);
         }
 

@@ -2866,11 +2866,11 @@
                         (void) strncpy(dep, d,  p - d + 1);
                         dep[p - d] = '\0';
 
                         _kobj_printf(ops, "%s: dependency ", modp->mod_modname);
                         _kobj_printf(ops, "'%s' too long ", dep);
-                        _kobj_printf(ops, "(max %d chars)\n", modnamelen);
+                        _kobj_printf(ops, "(max %d chars)\n", (int)modnamelen);
 
                         kobj_free(dep, p - d + 1);
 
                         return (-1);
                 }

@@ -3818,11 +3818,11 @@
         int page_addr;
 
         if (_moddebug & MODDEBUG_ERRMSG) {
                 _kobj_printf(ops, "kobj_read_file: size=%x,", size);
                 _kobj_printf(ops, " offset=%x at", off);
-                _kobj_printf(ops, " buf=%x\n", buf);
+                _kobj_printf(ops, " buf=%lx\n", (uintptr_t)buf);
         }
 
         /*
          * Handle compressed (gzip for now) file here. First get the
          * compressed size, then read the image into memory and finally

@@ -3861,11 +3861,11 @@
                         return (-1);
                 }
 
                 if (dlen != size) {
                         _kobj_printf(ops, "kobj_read_file: z_uncompress "
-                            "failed to uncompress (size returned 0x%x , "
+                            "failed to uncompress (size returned 0x%lx , "
                             "expected size: 0x%x)\n", dlen, size);
                         return (-1);
                 }
 
                 return (0);