Skip to content

Commit 5b5e092

Browse files
Alexey Dobriyantorvalds
authored andcommitted
lib/vsprintf.c: remove %Z support
Now that %z is standartised in C99 there is no reason to support %Z. Unlike %L it doesn't even make format strings smaller. Use BUILD_BUG_ON in a couple ATM drivers. In case anyone didn't notice lib/vsprintf.o is about half of SLUB which is in my opinion is quite an achievement. Hopefully this patch inspires someone else to trim vsprintf.c more. Link: http://lkml.kernel.org/r/20170103230126.GA30170@avx2 Signed-off-by: Alexey Dobriyan <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Rasmus Villemoes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d7f6724 commit 5b5e092

File tree

79 files changed

+187
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+187
-201
lines changed

block/bsg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
573573
int ret;
574574
ssize_t bytes_read;
575575

576-
dprintk("%s: read %Zd bytes\n", bd->name, count);
576+
dprintk("%s: read %zd bytes\n", bd->name, count);
577577

578578
bsg_set_block(bd, file);
579579

@@ -648,7 +648,7 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
648648
ssize_t bytes_written;
649649
int ret;
650650

651-
dprintk("%s: write %Zd bytes\n", bd->name, count);
651+
dprintk("%s: write %zd bytes\n", bd->name, count);
652652

653653
if (unlikely(segment_eq(get_fs(), KERNEL_DS)))
654654
return -EINVAL;
@@ -667,7 +667,7 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
667667
if (!bytes_written || err_block_err(ret))
668668
bytes_written = ret;
669669

670-
dprintk("%s: returning %Zd\n", bd->name, bytes_written);
670+
dprintk("%s: returning %zd\n", bd->name, bytes_written);
671671
return bytes_written;
672672
}
673673

drivers/atm/ambassador.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,12 +2394,7 @@ static int __init amb_module_init (void)
23942394
{
23952395
PRINTD (DBG_FLOW|DBG_INIT, "init_module");
23962396

2397-
// sanity check - cast needed as printk does not support %Zu
2398-
if (sizeof(amb_mem) != 4*16 + 4*12) {
2399-
PRINTK (KERN_ERR, "Fix amb_mem (is %lu words).",
2400-
(unsigned long) sizeof(amb_mem));
2401-
return -ENOMEM;
2402-
}
2397+
BUILD_BUG_ON(sizeof(amb_mem) != 4*16 + 4*12);
24032398

24042399
show_version();
24052400

drivers/atm/eni.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,11 +2326,7 @@ static int __init eni_init(void)
23262326
{
23272327
struct sk_buff *skb; /* dummy for sizeof */
23282328

2329-
if (sizeof(skb->cb) < sizeof(struct eni_skb_prv)) {
2330-
printk(KERN_ERR "eni_detect: skb->cb is too small (%Zd < %Zd)\n",
2331-
sizeof(skb->cb),sizeof(struct eni_skb_prv));
2332-
return -EIO;
2333-
}
2329+
BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct eni_skb_prv));
23342330
return pci_register_driver(&eni_driver);
23352331
}
23362332

drivers/atm/firestream.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
895895
/* XXX handle qos parameters (rate limiting) ? */
896896

897897
vcc = kmalloc(sizeof(struct fs_vcc), GFP_KERNEL);
898-
fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%Zd)\n", vcc, sizeof(struct fs_vcc));
898+
fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%zd)\n", vcc, sizeof(struct fs_vcc));
899899
if (!vcc) {
900900
clear_bit(ATM_VF_ADDR, &atm_vcc->flags);
901901
return -ENOMEM;
@@ -946,7 +946,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
946946

947947
if (DO_DIRECTION (txtp)) {
948948
tc = kmalloc (sizeof (struct fs_transmit_config), GFP_KERNEL);
949-
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%Zd)\n",
949+
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%zd)\n",
950950
tc, sizeof (struct fs_transmit_config));
951951
if (!tc) {
952952
fs_dprintk (FS_DEBUG_OPEN, "fs: can't alloc transmit_config.\n");
@@ -1185,7 +1185,7 @@ static int fs_send (struct atm_vcc *atm_vcc, struct sk_buff *skb)
11851185
vcc->last_skb = skb;
11861186

11871187
td = kmalloc (sizeof (struct FS_BPENTRY), GFP_ATOMIC);
1188-
fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%Zd)\n", td, sizeof (struct FS_BPENTRY));
1188+
fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%zd)\n", td, sizeof (struct FS_BPENTRY));
11891189
if (!td) {
11901190
/* Oops out of mem */
11911191
return -ENOMEM;
@@ -1492,7 +1492,7 @@ static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
14921492
fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-skb: %p(%d)\n", skb, fp->bufsize);
14931493
if (!skb) break;
14941494
ne = kmalloc (sizeof (struct FS_BPENTRY), gfp_flags);
1495-
fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%Zd)\n", ne, sizeof (struct FS_BPENTRY));
1495+
fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%zd)\n", ne, sizeof (struct FS_BPENTRY));
14961496
if (!ne) {
14971497
fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p\n", skb);
14981498
dev_kfree_skb_any (skb);
@@ -1803,7 +1803,7 @@ static int fs_init(struct fs_dev *dev)
18031803
}
18041804
dev->atm_vccs = kcalloc (dev->nchannels, sizeof (struct atm_vcc *),
18051805
GFP_KERNEL);
1806-
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
1806+
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%zd)\n",
18071807
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
18081808

18091809
if (!dev->atm_vccs) {
@@ -1911,7 +1911,7 @@ static int firestream_init_one(struct pci_dev *pci_dev,
19111911
goto err_out;
19121912

19131913
fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
1914-
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
1914+
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%zd)\n",
19151915
fs_dev, sizeof (struct fs_dev));
19161916
if (!fs_dev)
19171917
goto err_out;

drivers/atm/horizon.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,12 +2884,7 @@ static struct pci_driver hrz_driver = {
28842884
/********** module entry **********/
28852885

28862886
static int __init hrz_module_init (void) {
2887-
// sanity check - cast is needed since printk does not support %Zu
2888-
if (sizeof(struct MEMMAP) != 128*1024/4) {
2889-
PRINTK (KERN_ERR, "Fix struct MEMMAP (is %lu fakewords).",
2890-
(unsigned long) sizeof(struct MEMMAP));
2891-
return -ENOMEM;
2892-
}
2887+
BUILD_BUG_ON(sizeof(struct MEMMAP) != 128*1024/4);
28932888

28942889
show_version();
28952890

drivers/atm/lanai.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
13891389
if (n < 0)
13901390
n += lanai_buf_size(&lvcc->rx.buf);
13911391
APRINTK(n >= 0 && n < lanai_buf_size(&lvcc->rx.buf) && !(n & 15),
1392-
"vcc_rx_aal5: n out of range (%d/%Zu)\n",
1392+
"vcc_rx_aal5: n out of range (%d/%zu)\n",
13931393
n, lanai_buf_size(&lvcc->rx.buf));
13941394
/* Recover the second-to-last word to get true pdu length */
13951395
if ((x = &end[-2]) < lvcc->rx.buf.start)
@@ -1493,9 +1493,9 @@ static int lanai_get_sized_buffer(struct lanai_dev *lanai,
14931493
return -ENOMEM;
14941494
if (unlikely(lanai_buf_size(buf) < size))
14951495
printk(KERN_WARNING DEV_LABEL "(itf %d): wanted %d bytes "
1496-
"for %s buffer, got only %Zu\n", lanai->number, size,
1496+
"for %s buffer, got only %zu\n", lanai->number, size,
14971497
name, lanai_buf_size(buf));
1498-
DPRINTK("Allocated %Zu byte %s buffer\n", lanai_buf_size(buf), name);
1498+
DPRINTK("Allocated %zu byte %s buffer\n", lanai_buf_size(buf), name);
14991499
return 0;
15001500
}
15011501

@@ -1586,7 +1586,7 @@ static int service_buffer_allocate(struct lanai_dev *lanai)
15861586
lanai->pci);
15871587
if (unlikely(lanai->service.start == NULL))
15881588
return -ENOMEM;
1589-
DPRINTK("allocated service buffer at 0x%08lX, size %Zu(%d)\n",
1589+
DPRINTK("allocated service buffer at 0x%08lX, size %zu(%d)\n",
15901590
(unsigned long) lanai->service.start,
15911591
lanai_buf_size(&lanai->service),
15921592
lanai_buf_size_cardorder(&lanai->service));
@@ -2467,8 +2467,8 @@ static int lanai_proc_read(struct atm_dev *atmdev, loff_t *pos, char *page)
24672467
(lanai->status & STATUS_LED) ? 1 : 0,
24682468
(lanai->status & STATUS_GPIN) ? 1 : 0);
24692469
if (left-- == 0)
2470-
return sprintf(page, "global buffer sizes: service=%Zu, "
2471-
"aal0_rx=%Zu\n", lanai_buf_size(&lanai->service),
2470+
return sprintf(page, "global buffer sizes: service=%zu, "
2471+
"aal0_rx=%zu\n", lanai_buf_size(&lanai->service),
24722472
lanai->naal0 ? lanai_buf_size(&lanai->aal0buf) : 0);
24732473
if (left-- == 0) {
24742474
get_statistics(lanai);
@@ -2513,7 +2513,7 @@ static int lanai_proc_read(struct atm_dev *atmdev, loff_t *pos, char *page)
25132513
left += sprintf(&page[left], ",\n rx_AAL=%d",
25142514
lvcc->rx.atmvcc->qos.aal == ATM_AAL5 ? 5 : 0);
25152515
if (lvcc->rx.atmvcc->qos.aal == ATM_AAL5)
2516-
left += sprintf(&page[left], ", rx_buf_size=%Zu, "
2516+
left += sprintf(&page[left], ", rx_buf_size=%zu, "
25172517
"rx_bad_len=%u,\n rx_service_trash=%u, "
25182518
"rx_service_stream=%u, rx_bad_crc=%u",
25192519
lanai_buf_size(&lvcc->rx.buf),
@@ -2524,7 +2524,7 @@ static int lanai_proc_read(struct atm_dev *atmdev, loff_t *pos, char *page)
25242524
}
25252525
if (lvcc->tx.atmvcc != NULL)
25262526
left += sprintf(&page[left], ",\n tx_AAL=%d, "
2527-
"tx_buf_size=%Zu, tx_qos=%cBR, tx_backlogged=%c",
2527+
"tx_buf_size=%zu, tx_qos=%cBR, tx_backlogged=%c",
25282528
lvcc->tx.atmvcc->qos.aal == ATM_AAL5 ? 5 : 0,
25292529
lanai_buf_size(&lvcc->tx.buf),
25302530
lvcc->tx.atmvcc == lanai->cbrvcc ? 'C' : 'U',

drivers/char/pcmcia/cm4000_cs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
10371037
clear_bit(LOCK_IO, &dev->flags);
10381038
wake_up_interruptible(&dev->ioq);
10391039

1040-
DEBUGP(2, dev, "<- cmm_read returns: rc = %Zi\n",
1040+
DEBUGP(2, dev, "<- cmm_read returns: rc = %zi\n",
10411041
(rc < 0 ? rc : count));
10421042
return rc < 0 ? rc : count;
10431043
}

drivers/char/pcmcia/cm4040_cs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
331331
}
332332

333333
if ((count < 5) || (count > READ_WRITE_BUFFER_SIZE)) {
334-
DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count);
334+
DEBUGP(2, dev, "<- cm4040_write buffersize=%zd < 5\n", count);
335335
return -EIO;
336336
}
337337

drivers/gpu/drm/mga/mga_drv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ do { \
266266
do { \
267267
if (MGA_VERBOSE) { \
268268
DRM_INFO("BEGIN_DMA(%d)\n", (n)); \
269-
DRM_INFO(" space=0x%x req=0x%Zx\n", \
269+
DRM_INFO(" space=0x%x req=0x%zx\n", \
270270
dev_priv->prim.space, (n) * DMA_BLOCK_SIZE); \
271271
} \
272272
prim = dev_priv->prim.start; \
@@ -313,7 +313,7 @@ do { \
313313
#define DMA_WRITE(offset, val) \
314314
do { \
315315
if (MGA_VERBOSE) \
316-
DRM_INFO(" DMA_WRITE( 0x%08x ) at 0x%04Zx\n", \
316+
DRM_INFO(" DMA_WRITE( 0x%08x ) at 0x%04zx\n", \
317317
(u32)(val), write + (offset) * sizeof(u32)); \
318318
*(volatile u32 *)(prim + write + (offset) * sizeof(u32)) = val; \
319319
} while (0)

drivers/ide/ide-acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ void ide_acpi_get_timing(ide_hwif_t *hwif)
447447
memcpy(&hwif->acpidata->gtm, out_obj->buffer.pointer,
448448
sizeof(struct GTM_buffer));
449449

450-
DEBPRINT("_GTM info: ptr: 0x%p, len: 0x%x, exp.len: 0x%Zx\n",
450+
DEBPRINT("_GTM info: ptr: 0x%p, len: 0x%x, exp.len: 0x%zx\n",
451451
out_obj->buffer.pointer, out_obj->buffer.length,
452452
sizeof(struct GTM_buffer));
453453

0 commit comments

Comments
 (0)