瀏覽代碼

[block] Quell spurious Coverity size mismatch warning

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 年之前
父節點
當前提交
e846bd22c3
共有 1 個文件被更改,包括 10 次插入6 次删除
  1. 10
    6
      src/core/sanboot.c

+ 10
- 6
src/core/sanboot.c 查看文件

466
 		.type = ISO9660_TYPE_PRIMARY,
466
 		.type = ISO9660_TYPE_PRIMARY,
467
 		.id = ISO9660_ID,
467
 		.id = ISO9660_ID,
468
 	};
468
 	};
469
-	struct iso9660_primary_descriptor *primary;
469
+	union {
470
+		struct iso9660_primary_descriptor primary;
471
+		char bytes[ISO9660_BLKSIZE];
472
+	} *scratch;
470
 	unsigned int blksize;
473
 	unsigned int blksize;
471
 	unsigned int blksize_shift;
474
 	unsigned int blksize_shift;
472
 	unsigned int lba;
475
 	unsigned int lba;
489
 	count = ( 1 << blksize_shift );
492
 	count = ( 1 << blksize_shift );
490
 
493
 
491
 	/* Allocate scratch area */
494
 	/* Allocate scratch area */
492
-	primary = malloc ( ISO9660_BLKSIZE );
493
-	if ( ! primary ) {
495
+	scratch = malloc ( ISO9660_BLKSIZE );
496
+	if ( ! scratch ) {
494
 		rc = -ENOMEM;
497
 		rc = -ENOMEM;
495
 		goto err_alloc;
498
 		goto err_alloc;
496
 	}
499
 	}
497
 
500
 
498
 	/* Read primary volume descriptor */
501
 	/* Read primary volume descriptor */
499
-	if ( ( rc = sandev_rw ( sandev, lba, count, virt_to_user ( primary ),
502
+	if ( ( rc = sandev_rw ( sandev, lba, count, virt_to_user ( scratch ),
500
 				block_read ) ) != 0 ) {
503
 				block_read ) ) != 0 ) {
501
 		DBGC ( sandev, "SAN %#02x could not read ISO9660 primary"
504
 		DBGC ( sandev, "SAN %#02x could not read ISO9660 primary"
502
 		       "volume descriptor: %s\n",
505
 		       "volume descriptor: %s\n",
505
 	}
508
 	}
506
 
509
 
507
 	/* Configure as CD-ROM if applicable */
510
 	/* Configure as CD-ROM if applicable */
508
-	if ( memcmp ( primary, &primary_check, sizeof ( primary_check ) ) == 0){
511
+	if ( memcmp ( &scratch->primary.fixed, &primary_check,
512
+		      sizeof ( primary_check ) ) == 0 ) {
509
 		DBGC ( sandev, "SAN %#02x contains an ISO9660 filesystem; "
513
 		DBGC ( sandev, "SAN %#02x contains an ISO9660 filesystem; "
510
 		       "treating as CD-ROM\n", sandev->drive );
514
 		       "treating as CD-ROM\n", sandev->drive );
511
 		sandev->blksize_shift = blksize_shift;
515
 		sandev->blksize_shift = blksize_shift;
513
 	}
517
 	}
514
 
518
 
515
  err_rw:
519
  err_rw:
516
-	free ( primary );
520
+	free ( scratch );
517
  err_alloc:
521
  err_alloc:
518
  invalid_blksize:
522
  invalid_blksize:
519
 	return rc;
523
 	return rc;

Loading…
取消
儲存