]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[image] Use image name rather than pointer value in all debug messages
authorMichael Brown <mcb30@ipxe.org>
Mon, 26 May 2025 17:22:07 +0000 (18:22 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 26 May 2025 17:22:07 +0000 (18:22 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/image/com32.c
src/arch/x86/image/comboot.c
src/arch/x86/image/nbi.c
src/arch/x86/image/pxe_image.c
src/core/cpio.c
src/image/gzip.c
src/image/zlib.c

index fe55a3ee08e711dabf424221f7b35cf915a80fb5..2b31fb2e588ef0ef6c5e61b0aef3f0f6f4508ba9 100644 (file)
@@ -62,8 +62,8 @@ static int com32_exec_loop ( struct image *image ) {
                memmap_describe ( COM32_START_PHYS, 1, &region );
                assert ( memmap_is_usable ( &region ) );
                avail_mem_top = ( COM32_START_PHYS + memmap_size ( &region ) );
-               DBGC ( image, "COM32 %p: available memory top = 0x%x\n",
-                      image, avail_mem_top );
+               DBGC ( image, "COM32 %s: available memory top = 0x%x\n",
+                      image->name, avail_mem_top );
                assert ( avail_mem_top != 0 );
 
                /* Hook COMBOOT API interrupts */
@@ -114,22 +114,22 @@ static int com32_exec_loop ( struct image *image ) {
                                               image->cmdline : "" ) ),
                          "i" ( COM32_START_PHYS )
                        : "memory" );
-               DBGC ( image, "COM32 %p: returned\n", image );
+               DBGC ( image, "COM32 %s: returned\n", image->name );
                break;
 
        case COMBOOT_EXIT:
-               DBGC ( image, "COM32 %p: exited\n", image );
+               DBGC ( image, "COM32 %s: exited\n", image->name );
                break;
 
        case COMBOOT_EXIT_RUN_KERNEL:
                assert ( image->replacement );
-               DBGC ( image, "COM32 %p: exited to run kernel %s\n",
-                      image, image->replacement->name );
+               DBGC ( image, "COM32 %s: exited to run kernel %s\n",
+                      image->name, image->replacement->name );
                break;
 
        case COMBOOT_EXIT_COMMAND:
-               DBGC ( image, "COM32 %p: exited after executing command\n",
-                      image );
+               DBGC ( image, "COM32 %s: exited after executing command\n",
+                      image->name );
                break;
 
        default:
@@ -159,8 +159,8 @@ static int com32_identify ( struct image *image ) {
                 * B8 FF 4C CD 21
                 */
                if ( memcmp ( image->data, magic, sizeof ( magic) ) == 0 ) {
-                       DBGC ( image, "COM32 %p: found magic number\n",
-                              image );
+                       DBGC ( image, "COM32 %s: found magic number\n",
+                              image->name );
                        return 0;
                }
        }
@@ -170,16 +170,16 @@ static int com32_identify ( struct image *image ) {
        ext = strrchr( image->name, '.' );
 
        if ( ! ext ) {
-               DBGC ( image, "COM32 %p: no extension\n",
-                      image );
+               DBGC ( image, "COM32 %s: no extension\n",
+                      image->name );
                return -ENOEXEC;
        }
 
        ++ext;
 
        if ( strcasecmp( ext, "c32" ) ) {
-               DBGC ( image, "COM32 %p: unrecognized extension %s\n",
-                      image, ext );
+               DBGC ( image, "COM32 %s: unrecognized extension %s\n",
+                      image->name, ext );
                return -ENOEXEC;
        }
 
@@ -201,8 +201,8 @@ static int com32_load_image ( struct image *image ) {
        memsz = filesz;
        buffer = phys_to_virt ( COM32_START_PHYS );
        if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
-               DBGC ( image, "COM32 %p: could not prepare segment: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "COM32 %s: could not prepare segment: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -230,8 +230,8 @@ static int com32_prepare_bounce_buffer ( struct image * image ) {
 
        /* Prepare, verify, and load the real-mode segment */
        if ( ( rc = prep_segment ( seg, filesz, memsz ) ) != 0 ) {
-               DBGC ( image, "COM32 %p: could not prepare bounce buffer segment: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "COM32 %s: could not prepare bounce buffer segment: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -247,8 +247,6 @@ static int com32_prepare_bounce_buffer ( struct image * image ) {
 static int com32_probe ( struct image *image ) {
        int rc;
 
-       DBGC ( image, "COM32 %p: name '%s'\n", image, image->name );
-
        /* Check if this is a COMBOOT image */
        if ( ( rc = com32_identify ( image ) ) != 0 ) {
                return rc;
index f717e1d32254acef0214a2da98d60785bce714cf..6eba027c66c0623cac5a3c0f254879252ecb10e9 100644 (file)
@@ -108,8 +108,8 @@ static void comboot_init_psp ( struct image * image, void *seg ) {
         * kilobytes; x * 1024 / 16 == x * 64 == x << 6 */
        psp->first_non_free_para = get_fbms() << 6;
 
-       DBGC ( image, "COMBOOT %p: first non-free paragraph = 0x%x\n",
-              image, psp->first_non_free_para );
+       DBGC ( image, "COMBOOT %s: first non-free paragraph = 0x%x\n",
+              image->name, psp->first_non_free_para );
 
        /* Copy the command line to the PSP */
        comboot_copy_cmdline ( image, seg );
@@ -172,22 +172,22 @@ static int comboot_exec_loop ( struct image *image ) {
                                    "xorw %%bp, %%bp\n\t"
                                    "lret\n\t" )
                                         : : "R" ( COMBOOT_PSP_SEG ) : "eax" );
-               DBGC ( image, "COMBOOT %p: returned\n", image );
+               DBGC ( image, "COMBOOT %s: returned\n", image->name );
                break;
 
        case COMBOOT_EXIT:
-               DBGC ( image, "COMBOOT %p: exited\n", image );
+               DBGC ( image, "COMBOOT %s: exited\n", image->name );
                break;
 
        case COMBOOT_EXIT_RUN_KERNEL:
                assert ( image->replacement );
-               DBGC ( image, "COMBOOT %p: exited to run kernel %s\n",
-                      image, image->replacement->name );
+               DBGC ( image, "COMBOOT %s: exited to run kernel %s\n",
+                      image->name, image->replacement->name );
                break;
 
        case COMBOOT_EXIT_COMMAND:
-               DBGC ( image, "COMBOOT %p: exited after executing command\n",
-                      image );
+               DBGC ( image, "COMBOOT %s: exited after executing command\n",
+                      image->name );
                break;
 
        default:
@@ -213,16 +213,16 @@ static int comboot_identify ( struct image *image ) {
        ext = strrchr( image->name, '.' );
 
        if ( ! ext ) {
-               DBGC ( image, "COMBOOT %p: no extension\n",
-                      image );
+               DBGC ( image, "COMBOOT %s: no extension\n",
+                      image->name );
                return -ENOEXEC;
        }
 
        ++ext;
 
        if ( strcasecmp( ext, "cbt" ) ) {
-               DBGC ( image, "COMBOOT %p: unrecognized extension %s\n",
-                      image, ext );
+               DBGC ( image, "COMBOOT %s: unrecognized extension %s\n",
+                      image->name, ext );
                return -ENOEXEC;
        }
 
@@ -251,8 +251,8 @@ static int comboot_prepare_segment ( struct image *image )
 
        /* Prepare, verify, and load the real-mode segment */
        if ( ( rc = prep_segment ( seg, filesz, memsz ) ) != 0 ) {
-               DBGC ( image, "COMBOOT %p: could not prepare segment: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "COMBOOT %s: could not prepare segment: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -274,9 +274,6 @@ static int comboot_prepare_segment ( struct image *image )
 static int comboot_probe ( struct image *image ) {
        int rc;
 
-       DBGC ( image, "COMBOOT %p: name '%s'\n",
-              image, image->name );
-
        /* Check if this is a COMBOOT image */
        if ( ( rc = comboot_identify ( image ) ) != 0 ) {
 
@@ -297,8 +294,8 @@ static int comboot_exec ( struct image *image ) {
 
        /* Sanity check for filesize */
        if( image->len >= 0xFF00 ) {
-               DBGC( image, "COMBOOT %p: image too large\n",
-                     image );
+               DBGC( image, "COMBOOT %s: image too large\n",
+                     image->name );
                return -ENOEXEC;
        }
 
index 0f57bdfcdf2c37faf0b6ed07e473fcf3da04b263..e0a46758eae783ad40dcec71c16919face45a8c5 100644 (file)
@@ -111,8 +111,8 @@ static int nbi_prepare_segment ( struct image *image, size_t offset __unused,
        int rc;
 
        if ( ( rc = prep_segment ( dest, filesz, memsz ) ) != 0 ) {
-               DBGC ( image, "NBI %p could not prepare segment: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "NBI %s could not prepare segment: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -174,8 +174,8 @@ static int nbi_process_segments ( struct image *image,
                sh = ( image->data + sh_off );
                if ( sh->length == 0 ) {
                        /* Avoid infinite loop? */
-                       DBGC ( image, "NBI %p invalid segheader length 0\n",
-                              image );
+                       DBGC ( image, "NBI %s invalid segheader length 0\n",
+                              image->name );
                        return -ENOEXEC;
                }
                
@@ -207,7 +207,8 @@ static int nbi_process_segments ( struct image *image,
                filesz = sh->imglength;
                memsz = sh->memlength;
                if ( ( offset + filesz ) > image->len ) {
-                       DBGC ( image, "NBI %p segment outside file\n", image );
+                       DBGC ( image, "NBI %s segment outside file\n",
+                              image->name );
                        return -ENOEXEC;
                }
                if ( ( rc = process ( image, offset, dest,
@@ -219,15 +220,16 @@ static int nbi_process_segments ( struct image *image,
                /* Next segheader */
                sh_off += NBI_LENGTH ( sh->length );
                if ( sh_off >= NBI_HEADER_LENGTH ) {
-                       DBGC ( image, "NBI %p header overflow\n", image );
+                       DBGC ( image, "NBI %s header overflow\n",
+                              image->name );
                        return -ENOEXEC;
                }
 
        } while ( ! NBI_LAST_SEGHEADER ( sh->flags ) );
 
        if ( offset != image->len ) {
-               DBGC ( image, "NBI %p length wrong (file %zd, metadata %zd)\n",
-                      image, image->len, offset );
+               DBGC ( image, "NBI %s length wrong (file %zd, metadata %zd)\n",
+                      image->name, image->len, offset );
                return -ENOEXEC;
        }
 
@@ -245,8 +247,8 @@ static int nbi_boot16 ( struct image *image,
        int discard_D, discard_S, discard_b;
        int32_t rc;
 
-       DBGC ( image, "NBI %p executing 16-bit image at %04x:%04x\n", image,
-              imgheader->execaddr.segoff.segment,
+       DBGC ( image, "NBI %s executing 16-bit image at %04x:%04x\n",
+              image->name, imgheader->execaddr.segoff.segment,
               imgheader->execaddr.segoff.offset );
 
        __asm__ __volatile__ (
@@ -288,8 +290,8 @@ static int nbi_boot32 ( struct image *image,
        int discard_D, discard_S, discard_b;
        int32_t rc;
 
-       DBGC ( image, "NBI %p executing 32-bit image at %lx\n",
-              image, imgheader->execaddr.linear );
+       DBGC ( image, "NBI %s executing 32-bit image at %lx\n",
+              image->name, imgheader->execaddr.linear );
 
        /* Jump to OS with flat physical addressing */
        __asm__ __volatile__ (
@@ -324,14 +326,15 @@ static int nbi_prepare_dhcp ( struct image *image ) {
 
        boot_netdev = last_opened_netdev();
        if ( ! boot_netdev ) {
-               DBGC ( image, "NBI %p could not identify a network device\n",
-                      image );
+               DBGC ( image, "NBI %s could not identify a network device\n",
+                      image->name );
                return -ENODEV;
        }
 
        if ( ( rc = create_fakedhcpack ( boot_netdev, basemem_packet,
                                         sizeof ( basemem_packet ) ) ) != 0 ) {
-               DBGC ( image, "NBI %p failed to build DHCP packet\n", image );
+               DBGC ( image, "NBI %s failed to build DHCP packet\n",
+                      image->name );
                return rc;
        }
 
@@ -352,7 +355,7 @@ static int nbi_exec ( struct image *image ) {
        /* Retrieve image header */
        imgheader = image->data;
 
-       DBGC ( image, "NBI %p placing header at %hx:%hx\n", image,
+       DBGC ( image, "NBI %s placing header at %hx:%hx\n", image->name,
               imgheader->location.segment, imgheader->location.offset );
 
        /* NBI files can have overlaps between segments; the bss of
@@ -387,12 +390,12 @@ static int nbi_exec ( struct image *image ) {
 
        if ( ! may_return ) {
                /* Cannot continue after shutdown() called */
-               DBGC ( image, "NBI %p returned %d from non-returnable image\n",
-                      image, rc  );
+               DBGC ( image, "NBI %s returned %d from non-returnable image\n",
+                      image->name, rc  );
                while ( 1 ) {}
        }
 
-       DBGC ( image, "NBI %p returned %d\n", image, rc );
+       DBGC ( image, "NBI %s returned %d\n", image->name, rc );
 
        return rc;
 }
@@ -408,14 +411,15 @@ static int nbi_probe ( struct image *image ) {
 
        /* If we don't have enough data give up */
        if ( image->len < NBI_HEADER_LENGTH ) {
-               DBGC ( image, "NBI %p too short for an NBI image\n", image );
+               DBGC ( image, "NBI %s too short for an NBI image\n",
+                      image->name );
                return -ENOEXEC;
        }
        imgheader = image->data;
 
        /* Check image header */
        if ( imgheader->magic != NBI_MAGIC ) {
-               DBGC ( image, "NBI %p has no NBI signature\n", image );
+               DBGC ( image, "NBI %s has no NBI signature\n", image->name );
                return -ENOEXEC;
        }
 
index ccb3a7d9d99ff9d960e20af44293c1efad0a1aa3..f88eadc0946ca81b5a9d31030d4508e710587461 100644 (file)
@@ -60,8 +60,8 @@ static int pxe_exec ( struct image *image ) {
 
        /* Verify and prepare segment */
        if ( ( rc = prep_segment ( buffer, image->len, image->len ) ) != 0 ) {
-               DBGC ( image, "IMAGE %p could not prepare segment: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "IMAGE %s could not prepare segment: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -70,8 +70,8 @@ static int pxe_exec ( struct image *image ) {
 
        /* Arbitrarily pick the most recently opened network device */
        if ( ( netdev = last_opened_netdev() ) == NULL ) {
-               DBGC ( image, "IMAGE %p could not locate PXE net device\n",
-                      image );
+               DBGC ( image, "IMAGE %s could not locate PXE net device\n",
+                      image->name );
                return -ENODEV;
        }
        netdev_get ( netdev );
@@ -155,8 +155,8 @@ int pxe_probe_no_mz ( struct image *image ) {
        if ( image->len >= sizeof ( *magic ) ) {
                magic = image->data;
                if ( *magic == cpu_to_le16 ( EFI_IMAGE_DOS_SIGNATURE ) ) {
-                       DBGC ( image, "IMAGE %p may be an EFI image\n",
-                              image );
+                       DBGC ( image, "IMAGE %s may be an EFI image\n",
+                              image->name );
                        return -ENOTTY;
                }
        }
index 9f5d772e9ac56850867c5799c325082b663af057..15e33d206d5e936b552be406569ff77e1114feed 100644 (file)
@@ -125,8 +125,8 @@ static void cpio_parse_cmdline ( struct image *image, unsigned int *mode,
        if ( ( arg = image_argument ( image, "mode=" ) ) ) {
                *mode = strtoul ( arg, &end, 8 /* Octal for file mode */ );
                if ( *end && ( *end != ' ' ) ) {
-                       DBGC ( image, "CPIO %p strange \"mode=\" "
-                              "terminator '%c'\n", image, *end );
+                       DBGC ( image, "CPIO %s strange \"mode=\" "
+                              "terminator '%c'\n", image->name, *end );
                }
        }
 
@@ -134,8 +134,8 @@ static void cpio_parse_cmdline ( struct image *image, unsigned int *mode,
        if ( ( arg = image_argument ( image, "mkdir=" ) ) ) {
                *count += strtoul ( arg, &end, 10 );
                if ( *end && ( *end != ' ' ) ) {
-                       DBGC ( image, "CPIO %p strange \"mkdir=\" "
-                              "terminator '%c'\n", image, *end );
+                       DBGC ( image, "CPIO %s strange \"mkdir=\" "
+                              "terminator '%c'\n", image->name, *end );
                }
        }
 
index b72c3243e27daac94d8b33c5463e7e823bf04278..17ccd2492b37423c7ec407c6edce794e6b26680c 100644 (file)
@@ -76,8 +76,8 @@ static int gzip_extract ( struct image *image, struct image *extracted ) {
        /* Skip extra header, if present */
        if ( header->flags & GZIP_FL_EXTRA ) {
                if ( len < sizeof ( *extra ) ) {
-                       DBGC ( image, "GZIP %p overlength extra header\n",
-                              image );
+                       DBGC ( image, "GZIP %s overlength extra header\n",
+                              image->name );
                        return -EINVAL;
                }
                extra = data;
@@ -85,8 +85,8 @@ static int gzip_extract ( struct image *image, struct image *extracted ) {
                len -= sizeof ( *extra );
                extra_len = le16_to_cpu ( extra->len );
                if ( len < extra_len ) {
-                       DBGC ( image, "GZIP %p overlength extra header\n",
-                              image );
+                       DBGC ( image, "GZIP %s overlength extra header\n",
+                              image->name );
                        return -EINVAL;
                }
                data += extra_len;
@@ -102,8 +102,8 @@ static int gzip_extract ( struct image *image, struct image *extracted ) {
        while ( strings-- ) {
                string_len = strnlen ( data, len );
                if ( string_len == len ) {
-                       DBGC ( image, "GZIP %p overlength name/comment\n",
-                              image );
+                       DBGC ( image, "GZIP %s overlength name/comment\n",
+                              image->name );
                        return -EINVAL;
                }
                data += ( string_len + 1 /* NUL */ );
@@ -113,8 +113,8 @@ static int gzip_extract ( struct image *image, struct image *extracted ) {
        /* Skip CRC, if present */
        if ( header->flags & GZIP_FL_HCRC ) {
                if ( len < sizeof ( *crc ) ) {
-                       DBGC ( image, "GZIP %p overlength CRC header\n",
-                              image );
+                       DBGC ( image, "GZIP %s overlength CRC header\n",
+                              image->name );
                        return -EINVAL;
                }
                data += sizeof ( *crc );
@@ -124,16 +124,16 @@ static int gzip_extract ( struct image *image, struct image *extracted ) {
        /* Presize extracted image */
        if ( ( rc = image_set_len ( extracted,
                                    le32_to_cpu ( footer->len ) ) ) != 0 ) {
-               DBGC ( image, "GZIP %p could not presize: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "GZIP %s could not presize: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
        /* Decompress image (expanding if necessary) */
        if ( ( rc = zlib_deflate ( DEFLATE_RAW, data, len,
                                   extracted ) ) != 0 ) {
-               DBGC ( image, "GZIP %p could not decompress: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "GZIP %s could not decompress: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -152,14 +152,14 @@ static int gzip_probe ( struct image *image ) {
 
        /* Sanity check */
        if ( image->len < ( sizeof ( *header ) + sizeof ( *footer ) ) ) {
-               DBGC ( image, "GZIP %p image too short\n", image );
+               DBGC ( image, "GZIP %s image too short\n", image->name );
                return -ENOEXEC;
        }
        header = image->data;
 
        /* Check magic header */
        if ( header->magic != cpu_to_be16 ( GZIP_MAGIC ) ) {
-               DBGC ( image, "GZIP %p invalid magic\n", image );
+               DBGC ( image, "GZIP %s invalid magic\n", image->name );
                return -ENOEXEC;
        }
 
index 23eb50e7d7724462ab10f4c7191d431413896ed3..f0f8f5622e6bec9c64e563244a0456b2c52f0714 100644 (file)
@@ -71,15 +71,15 @@ int zlib_deflate ( enum deflate_format format, const void *data, size_t len,
                /* Decompress data */
                if ( ( rc = deflate_inflate ( deflate, data, len,
                                              &out ) ) != 0 ) {
-                       DBGC ( extracted, "ZLIB %p could not decompress: %s\n",
-                              extracted, strerror ( rc ) );
+                       DBGC ( extracted, "ZLIB %s could not decompress: %s\n",
+                              extracted->name, strerror ( rc ) );
                        goto err_inflate;
                }
 
                /* Check that decompression is valid */
                if ( ! deflate_finished ( deflate ) ) {
-                       DBGC ( extracted, "ZLIB %p decompression incomplete\n",
-                              extracted );
+                       DBGC ( extracted, "ZLIB %s decompression incomplete\n",
+                              extracted->name );
                        rc = -EINVAL;
                        goto err_unfinished;
                }
@@ -90,8 +90,8 @@ int zlib_deflate ( enum deflate_format format, const void *data, size_t len,
 
                /* Otherwise, resize output image and retry */
                if ( ( rc = image_set_len ( extracted, out.offset ) ) != 0 ) {
-                       DBGC ( extracted, "ZLIB %p could not resize: %s\n",
-                              extracted, strerror ( rc ) );
+                       DBGC ( extracted, "ZLIB %s could not resize: %s\n",
+                              extracted->name, strerror ( rc ) );
                        goto err_set_size;
                }
        }
@@ -136,14 +136,14 @@ static int zlib_probe ( struct image *image ) {
 
        /* Sanity check */
        if ( image->len < sizeof ( *magic ) ) {
-               DBGC ( image, "ZLIB %p image too short\n", image );
+               DBGC ( image, "ZLIB %s image too short\n", image->name );
                return -ENOEXEC;
        }
        magic = image->data;
 
        /* Check magic header */
        if ( ! zlib_magic_is_valid ( magic ) ) {
-               DBGC ( image, "ZLIB %p invalid magic data\n", image );
+               DBGC ( image, "ZLIB %s invalid magic data\n", image->name );
                return -ENOEXEC;
        }