Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

udf: Fix signed/unsigned format specifiers

Fix problems noted in compilion with -Wformat=2 -Wformat-signedness.
In particular, a mismatch between the signedness of a value and the
signedness of its format specifier can result in unsigned values being
printed as negative numbers, e.g.:

Partition (0 type 1511) starts at physical 460, block length -1779968542

...which occurs when mounting a large (> 1 TiB) UDF partition.

Changes since V1:
* Fixed additional issues noted in udf_bitmap_free_blocks(),
udf_get_fileident(), udf_show_options()

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Steve Magnani and committed by
Jan Kara
fcbf7637 b490bdd6

+49 -49
+6 -6
fs/udf/balloc.c
··· 58 58 int nr_groups = bitmap->s_nr_groups; 59 59 60 60 if (block_group >= nr_groups) { 61 - udf_debug("block_group (%d) > nr_groups (%d)\n", 61 + udf_debug("block_group (%u) > nr_groups (%d)\n", 62 62 block_group, nr_groups); 63 63 } 64 64 ··· 122 122 partmap = &sbi->s_partmaps[bloc->partitionReferenceNum]; 123 123 if (bloc->logicalBlockNum + count < count || 124 124 (bloc->logicalBlockNum + count) > partmap->s_partition_len) { 125 - udf_debug("%d < %d || %d + %d > %d\n", 125 + udf_debug("%u < %d || %u + %u > %u\n", 126 126 bloc->logicalBlockNum, 0, 127 127 bloc->logicalBlockNum, count, 128 128 partmap->s_partition_len); ··· 151 151 bh = bitmap->s_block_bitmap[bitmap_nr]; 152 152 for (i = 0; i < count; i++) { 153 153 if (udf_set_bit(bit + i, bh->b_data)) { 154 - udf_debug("bit %ld already set\n", bit + i); 154 + udf_debug("bit %lu already set\n", bit + i); 155 155 udf_debug("byte=%2x\n", 156 - ((char *)bh->b_data)[(bit + i) >> 3]); 156 + ((__u8 *)bh->b_data)[(bit + i) >> 3]); 157 157 } 158 158 } 159 159 udf_add_free_space(sb, sbi->s_partition, count); ··· 364 364 partmap = &sbi->s_partmaps[bloc->partitionReferenceNum]; 365 365 if (bloc->logicalBlockNum + count < count || 366 366 (bloc->logicalBlockNum + count) > partmap->s_partition_len) { 367 - udf_debug("%d < %d || %d + %d > %d\n", 367 + udf_debug("%u < %d || %u + %u > %u\n", 368 368 bloc->logicalBlockNum, 0, 369 369 bloc->logicalBlockNum, count, 370 370 partmap->s_partition_len); ··· 517 517 518 518 while (first_block != eloc.logicalBlockNum && 519 519 (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { 520 - udf_debug("eloc=%d, elen=%d, first_block=%d\n", 520 + udf_debug("eloc=%u, elen=%u, first_block=%u\n", 521 521 eloc.logicalBlockNum, elen, first_block); 522 522 ; /* empty loop body */ 523 523 }
+1 -1
fs/udf/directory.c
··· 176 176 if (fi->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FID)) { 177 177 udf_debug("0x%x != TAG_IDENT_FID\n", 178 178 le16_to_cpu(fi->descTag.tagIdent)); 179 - udf_debug("offset: %u sizeof: %lu bufsize: %u\n", 179 + udf_debug("offset: %d sizeof: %lu bufsize: %d\n", 180 180 *offset, (unsigned long)sizeof(struct fileIdentDesc), 181 181 bufsize); 182 182 return NULL;
+8 -8
fs/udf/inode.c
··· 1278 1278 1279 1279 reread: 1280 1280 if (iloc->partitionReferenceNum >= sbi->s_partitions) { 1281 - udf_debug("partition reference: %d > logical volume partitions: %d\n", 1281 + udf_debug("partition reference: %u > logical volume partitions: %u\n", 1282 1282 iloc->partitionReferenceNum, sbi->s_partitions); 1283 1283 return -EIO; 1284 1284 } 1285 1285 1286 1286 if (iloc->logicalBlockNum >= 1287 1287 sbi->s_partmaps[iloc->partitionReferenceNum].s_partition_len) { 1288 - udf_debug("block=%d, partition=%d out of range\n", 1288 + udf_debug("block=%u, partition=%u out of range\n", 1289 1289 iloc->logicalBlockNum, iloc->partitionReferenceNum); 1290 1290 return -EIO; 1291 1291 } ··· 1304 1304 */ 1305 1305 bh = udf_read_ptagged(inode->i_sb, iloc, 0, &ident); 1306 1306 if (!bh) { 1307 - udf_err(inode->i_sb, "(ino %ld) failed !bh\n", inode->i_ino); 1307 + udf_err(inode->i_sb, "(ino %lu) failed !bh\n", inode->i_ino); 1308 1308 return -EIO; 1309 1309 } 1310 1310 1311 1311 if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && 1312 1312 ident != TAG_IDENT_USE) { 1313 - udf_err(inode->i_sb, "(ino %ld) failed ident=%d\n", 1313 + udf_err(inode->i_sb, "(ino %lu) failed ident=%u\n", 1314 1314 inode->i_ino, ident); 1315 1315 goto out; 1316 1316 } ··· 1346 1346 } 1347 1347 brelse(ibh); 1348 1348 } else if (fe->icbTag.strategyType != cpu_to_le16(4)) { 1349 - udf_err(inode->i_sb, "unsupported strategy type: %d\n", 1349 + udf_err(inode->i_sb, "unsupported strategy type: %u\n", 1350 1350 le16_to_cpu(fe->icbTag.strategyType)); 1351 1351 goto out; 1352 1352 } ··· 1547 1547 udf_debug("METADATA BITMAP FILE-----\n"); 1548 1548 break; 1549 1549 default: 1550 - udf_err(inode->i_sb, "(ino %ld) failed unknown file type=%d\n", 1550 + udf_err(inode->i_sb, "(ino %lu) failed unknown file type=%u\n", 1551 1551 inode->i_ino, fe->icbTag.fileType); 1552 1552 goto out; 1553 1553 } ··· 2091 2091 block = udf_get_lb_pblock(inode->i_sb, &epos->block, 0); 2092 2092 epos->bh = udf_tread(inode->i_sb, block); 2093 2093 if (!epos->bh) { 2094 - udf_debug("reading block %d failed!\n", block); 2094 + udf_debug("reading block %u failed!\n", block); 2095 2095 return -1; 2096 2096 } 2097 2097 } ··· 2146 2146 *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; 2147 2147 break; 2148 2148 default: 2149 - udf_debug("alloc_type = %d unsupported\n", iinfo->i_alloc_type); 2149 + udf_debug("alloc_type = %u unsupported\n", iinfo->i_alloc_type); 2150 2150 return -1; 2151 2151 } 2152 2152
+2 -2
fs/udf/misc.c
··· 209 209 210 210 bh = udf_tread(sb, block); 211 211 if (!bh) { 212 - udf_err(sb, "read failed, block=%u, location=%d\n", 212 + udf_err(sb, "read failed, block=%u, location=%u\n", 213 213 block, location); 214 214 return NULL; 215 215 } ··· 247 247 le16_to_cpu(tag_p->descCRCLength))) 248 248 return bh; 249 249 250 - udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block, 250 + udf_debug("Crc failure block %u: crc = %u, crclen = %u\n", block, 251 251 le16_to_cpu(tag_p->descCRC), 252 252 le16_to_cpu(tag_p->descCRCLength)); 253 253 error_out:
+2 -2
fs/udf/namei.c
··· 840 840 if (retval) 841 841 goto end_rmdir; 842 842 if (inode->i_nlink != 2) 843 - udf_warn(inode->i_sb, "empty directory has nlink != 2 (%d)\n", 843 + udf_warn(inode->i_sb, "empty directory has nlink != 2 (%u)\n", 844 844 inode->i_nlink); 845 845 clear_nlink(inode); 846 846 inode->i_size = 0; ··· 882 882 goto end_unlink; 883 883 884 884 if (!inode->i_nlink) { 885 - udf_debug("Deleting nonexistent file (%lu), %d\n", 885 + udf_debug("Deleting nonexistent file (%lu), %u\n", 886 886 inode->i_ino, inode->i_nlink); 887 887 set_nlink(inode, 1); 888 888 }
+3 -3
fs/udf/partition.c
··· 32 32 struct udf_sb_info *sbi = UDF_SB(sb); 33 33 struct udf_part_map *map; 34 34 if (partition >= sbi->s_partitions) { 35 - udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n", 35 + udf_debug("block=%u, partition=%u, offset=%u: invalid partition\n", 36 36 block, partition, offset); 37 37 return 0xFFFFFFFF; 38 38 } ··· 59 59 vdata = &map->s_type_specific.s_virtual; 60 60 61 61 if (block > vdata->s_num_entries) { 62 - udf_debug("Trying to access block beyond end of VAT (%d max %d)\n", 62 + udf_debug("Trying to access block beyond end of VAT (%u max %u)\n", 63 63 block, vdata->s_num_entries); 64 64 return 0xFFFFFFFF; 65 65 } ··· 83 83 84 84 bh = sb_bread(sb, loc); 85 85 if (!bh) { 86 - udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n", 86 + udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%u,%u) VAT: %u[%u]\n", 87 87 sb, block, partition, loc, index); 88 88 return 0xFFFFFFFF; 89 89 }
+26 -26
fs/udf/super.c
··· 366 366 if (sbi->s_dmode != UDF_INVALID_MODE) 367 367 seq_printf(seq, ",dmode=%ho", sbi->s_dmode); 368 368 if (UDF_QUERY_FLAG(sb, UDF_FLAG_SESSION_SET)) 369 - seq_printf(seq, ",session=%u", sbi->s_session); 369 + seq_printf(seq, ",session=%d", sbi->s_session); 370 370 if (UDF_QUERY_FLAG(sb, UDF_FLAG_LASTBLOCK_SET)) 371 371 seq_printf(seq, ",lastblock=%u", sbi->s_last_block); 372 372 if (sbi->s_anchor != 0) ··· 705 705 706 706 sector += (((loff_t)sbi->s_session) << sb->s_blocksize_bits); 707 707 708 - udf_debug("Starting at sector %u (%ld byte sectors)\n", 708 + udf_debug("Starting at sector %u (%lu byte sectors)\n", 709 709 (unsigned int)(sector >> sb->s_blocksize_bits), 710 710 sb->s_blocksize); 711 711 /* Process the sequence (if applicable). The hard limit on the sector ··· 868 868 869 869 if ((fileset->logicalBlockNum != 0xFFFFFFFF || 870 870 fileset->partitionReferenceNum != 0xFFFF) && bh) { 871 - udf_debug("Fileset at block=%d, partition=%d\n", 871 + udf_debug("Fileset at block=%u, partition=%u\n", 872 872 fileset->logicalBlockNum, 873 873 fileset->partitionReferenceNum); 874 874 ··· 981 981 mdata->s_phys_partition_ref = type1_index; 982 982 983 983 /* metadata address */ 984 - udf_debug("Metadata file location: block = %d part = %d\n", 984 + udf_debug("Metadata file location: block = %u part = %u\n", 985 985 mdata->s_meta_file_loc, mdata->s_phys_partition_ref); 986 986 987 987 fe = udf_find_metadata_inode_efe(sb, mdata->s_meta_file_loc, 988 988 mdata->s_phys_partition_ref); 989 989 if (IS_ERR(fe)) { 990 990 /* mirror file entry */ 991 - udf_debug("Mirror metadata file location: block = %d part = %d\n", 991 + udf_debug("Mirror metadata file location: block = %u part = %u\n", 992 992 mdata->s_mirror_file_loc, mdata->s_phys_partition_ref); 993 993 994 994 fe = udf_find_metadata_inode_efe(sb, mdata->s_mirror_file_loc, ··· 1012 1012 addr.logicalBlockNum = mdata->s_bitmap_file_loc; 1013 1013 addr.partitionReferenceNum = mdata->s_phys_partition_ref; 1014 1014 1015 - udf_debug("Bitmap file location: block = %d part = %d\n", 1015 + udf_debug("Bitmap file location: block = %u part = %u\n", 1016 1016 addr.logicalBlockNum, addr.partitionReferenceNum); 1017 1017 1018 1018 fe = udf_iget_special(sb, &addr); ··· 1042 1042 1043 1043 UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum); 1044 1044 1045 - udf_debug("Rootdir at block=%d, partition=%d\n", 1045 + udf_debug("Rootdir at block=%u, partition=%u\n", 1046 1046 root->logicalBlockNum, root->partitionReferenceNum); 1047 1047 } 1048 1048 ··· 1097 1097 if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE)) 1098 1098 map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE; 1099 1099 1100 - udf_debug("Partition (%d type %x) starts at physical %d, block length %d\n", 1100 + udf_debug("Partition (%d type %x) starts at physical %u, block length %u\n", 1101 1101 p_index, map->s_partition_type, 1102 1102 map->s_partition_root, map->s_partition_len); 1103 1103 ··· 1122 1122 } 1123 1123 map->s_uspace.s_table = inode; 1124 1124 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; 1125 - udf_debug("unallocSpaceTable (part %d) @ %ld\n", 1125 + udf_debug("unallocSpaceTable (part %d) @ %lu\n", 1126 1126 p_index, map->s_uspace.s_table->i_ino); 1127 1127 } 1128 1128 ··· 1134 1134 bitmap->s_extPosition = le32_to_cpu( 1135 1135 phd->unallocSpaceBitmap.extPosition); 1136 1136 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; 1137 - udf_debug("unallocSpaceBitmap (part %d) @ %d\n", 1137 + udf_debug("unallocSpaceBitmap (part %d) @ %u\n", 1138 1138 p_index, bitmap->s_extPosition); 1139 1139 } 1140 1140 ··· 1157 1157 } 1158 1158 map->s_fspace.s_table = inode; 1159 1159 map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; 1160 - udf_debug("freedSpaceTable (part %d) @ %ld\n", 1160 + udf_debug("freedSpaceTable (part %d) @ %lu\n", 1161 1161 p_index, map->s_fspace.s_table->i_ino); 1162 1162 } 1163 1163 ··· 1169 1169 bitmap->s_extPosition = le32_to_cpu( 1170 1170 phd->freedSpaceBitmap.extPosition); 1171 1171 map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; 1172 - udf_debug("freedSpaceBitmap (part %d) @ %d\n", 1172 + udf_debug("freedSpaceBitmap (part %d) @ %u\n", 1173 1173 p_index, bitmap->s_extPosition); 1174 1174 } 1175 1175 return 0; ··· 1282 1282 /* First scan for TYPE1 and SPARABLE partitions */ 1283 1283 for (i = 0; i < sbi->s_partitions; i++) { 1284 1284 map = &sbi->s_partmaps[i]; 1285 - udf_debug("Searching map: (%d == %d)\n", 1285 + udf_debug("Searching map: (%u == %u)\n", 1286 1286 map->s_partition_num, partitionNumber); 1287 1287 if (map->s_partition_num == partitionNumber && 1288 1288 (map->s_partition_type == UDF_TYPE1_MAP15 || ··· 1291 1291 } 1292 1292 1293 1293 if (i >= sbi->s_partitions) { 1294 - udf_debug("Partition (%d) not found in partition map\n", 1294 + udf_debug("Partition (%u) not found in partition map\n", 1295 1295 partitionNumber); 1296 1296 ret = 0; 1297 1297 goto out_bh; ··· 1483 1483 struct metadataPartitionMap *mdm = 1484 1484 (struct metadataPartitionMap *) 1485 1485 &(lvd->partitionMaps[offset]); 1486 - udf_debug("Parsing Logical vol part %d type %d id=%s\n", 1486 + udf_debug("Parsing Logical vol part %d type %u id=%s\n", 1487 1487 i, type, UDF_ID_METADATA); 1488 1488 1489 1489 map->s_partition_type = UDF_METADATA_MAP25; ··· 1505 1505 udf_debug("Metadata Ident suffix=0x%x\n", 1506 1506 le16_to_cpu(*(__le16 *) 1507 1507 mdm->partIdent.identSuffix)); 1508 - udf_debug("Metadata part num=%d\n", 1508 + udf_debug("Metadata part num=%u\n", 1509 1509 le16_to_cpu(mdm->partitionNum)); 1510 - udf_debug("Metadata part alloc unit size=%d\n", 1510 + udf_debug("Metadata part alloc unit size=%u\n", 1511 1511 le32_to_cpu(mdm->allocUnitSize)); 1512 - udf_debug("Metadata file loc=%d\n", 1512 + udf_debug("Metadata file loc=%u\n", 1513 1513 le32_to_cpu(mdm->metadataFileLoc)); 1514 - udf_debug("Mirror file loc=%d\n", 1514 + udf_debug("Mirror file loc=%u\n", 1515 1515 le32_to_cpu(mdm->metadataMirrorFileLoc)); 1516 - udf_debug("Bitmap file loc=%d\n", 1516 + udf_debug("Bitmap file loc=%u\n", 1517 1517 le32_to_cpu(mdm->metadataBitmapFileLoc)); 1518 - udf_debug("Flags: %d %d\n", 1518 + udf_debug("Flags: %d %u\n", 1519 1519 mdata->s_flags, mdm->flags); 1520 1520 } else { 1521 1521 udf_debug("Unknown ident: %s\n", ··· 1525 1525 map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum); 1526 1526 map->s_partition_num = le16_to_cpu(upm2->partitionNum); 1527 1527 } 1528 - udf_debug("Partition (%d:%d) type %d on volume %d\n", 1528 + udf_debug("Partition (%d:%u) type %u on volume %u\n", 1529 1529 i, map->s_partition_num, type, map->s_volumeseqnum); 1530 1530 } 1531 1531 ··· 1533 1533 struct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]); 1534 1534 1535 1535 *fileset = lelb_to_cpu(la->extLocation); 1536 - udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", 1536 + udf_debug("FileSet found in LogicalVolDesc at block=%u, partition=%u\n", 1537 1537 fileset->logicalBlockNum, 1538 1538 fileset->partitionReferenceNum); 1539 1539 } ··· 2159 2159 ret = udf_load_vrs(sb, &uopt, silent, &fileset); 2160 2160 if (ret < 0) { 2161 2161 if (!silent && ret != -EACCES) { 2162 - pr_notice("Scanning with blocksize %d failed\n", 2162 + pr_notice("Scanning with blocksize %u failed\n", 2163 2163 uopt.blocksize); 2164 2164 } 2165 2165 brelse(sbi->s_lvid_bh); ··· 2184 2184 goto error_out; 2185 2185 } 2186 2186 2187 - udf_debug("Lastblock=%d\n", sbi->s_last_block); 2187 + udf_debug("Lastblock=%u\n", sbi->s_last_block); 2188 2188 2189 2189 if (sbi->s_lvid_bh) { 2190 2190 struct logicalVolIntegrityDescImpUse *lvidiu = ··· 2255 2255 /* perhaps it's not extensible enough, but for now ... */ 2256 2256 inode = udf_iget(sb, &rootdir); 2257 2257 if (IS_ERR(inode)) { 2258 - udf_err(sb, "Error in udf_iget, block=%d, partition=%d\n", 2258 + udf_err(sb, "Error in udf_iget, block=%u, partition=%u\n", 2259 2259 rootdir.logicalBlockNum, rootdir.partitionReferenceNum); 2260 2260 ret = PTR_ERR(inode); 2261 2261 goto error_out;
+1 -1
fs/udf/unicode.c
··· 200 200 cmp_id = ocu[0]; 201 201 if (cmp_id != 8 && cmp_id != 16) { 202 202 memset(str_o, 0, str_max_len); 203 - pr_err("unknown compression code (%d)\n", cmp_id); 203 + pr_err("unknown compression code (%u)\n", cmp_id); 204 204 return -EINVAL; 205 205 } 206 206 u_ch = cmp_id >> 3;