Commit 01d1a791 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] snprintf fixes

From: Juergen Quade <quade@hsnr.de>

Lots of places in the kernel are using [v]snprintf wrongly: they assume it
returns the number of characters copied.  It doesn't.  It returns the
number of characters which _would_ have been copied had the buffer not been
filled up.

So create new functions vscnprintf() and scnprintf() which have the
expected (sane) semaptics, and migrate callers over to using them.
parent 53b15b86
...@@ -134,18 +134,18 @@ edd_show_host_bus(struct edd_device *edev, char *buf) ...@@ -134,18 +134,18 @@ edd_show_host_bus(struct edd_device *edev, char *buf)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (isprint(info->params.host_bus_type[i])) { if (isprint(info->params.host_bus_type[i])) {
p += snprintf(p, left, "%c", info->params.host_bus_type[i]); p += scnprintf(p, left, "%c", info->params.host_bus_type[i]);
} else { } else {
p += snprintf(p, left, " "); p += scnprintf(p, left, " ");
} }
} }
if (!strncmp(info->params.host_bus_type, "ISA", 3)) { if (!strncmp(info->params.host_bus_type, "ISA", 3)) {
p += snprintf(p, left, "\tbase_address: %x\n", p += scnprintf(p, left, "\tbase_address: %x\n",
info->params.interface_path.isa.base_address); info->params.interface_path.isa.base_address);
} else if (!strncmp(info->params.host_bus_type, "PCIX", 4) || } else if (!strncmp(info->params.host_bus_type, "PCIX", 4) ||
!strncmp(info->params.host_bus_type, "PCI", 3)) { !strncmp(info->params.host_bus_type, "PCI", 3)) {
p += snprintf(p, left, p += scnprintf(p, left,
"\t%02x:%02x.%d channel: %u\n", "\t%02x:%02x.%d channel: %u\n",
info->params.interface_path.pci.bus, info->params.interface_path.pci.bus,
info->params.interface_path.pci.slot, info->params.interface_path.pci.slot,
...@@ -154,12 +154,12 @@ edd_show_host_bus(struct edd_device *edev, char *buf) ...@@ -154,12 +154,12 @@ edd_show_host_bus(struct edd_device *edev, char *buf)
} else if (!strncmp(info->params.host_bus_type, "IBND", 4) || } else if (!strncmp(info->params.host_bus_type, "IBND", 4) ||
!strncmp(info->params.host_bus_type, "XPRS", 4) || !strncmp(info->params.host_bus_type, "XPRS", 4) ||
!strncmp(info->params.host_bus_type, "HTPT", 4)) { !strncmp(info->params.host_bus_type, "HTPT", 4)) {
p += snprintf(p, left, p += scnprintf(p, left,
"\tTBD: %llx\n", "\tTBD: %llx\n",
info->params.interface_path.ibnd.reserved); info->params.interface_path.ibnd.reserved);
} else { } else {
p += snprintf(p, left, "\tunknown: %llx\n", p += scnprintf(p, left, "\tunknown: %llx\n",
info->params.interface_path.unknown.reserved); info->params.interface_path.unknown.reserved);
} }
return (p - buf); return (p - buf);
...@@ -178,43 +178,43 @@ edd_show_interface(struct edd_device *edev, char *buf) ...@@ -178,43 +178,43 @@ edd_show_interface(struct edd_device *edev, char *buf)
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (isprint(info->params.interface_type[i])) { if (isprint(info->params.interface_type[i])) {
p += snprintf(p, left, "%c", info->params.interface_type[i]); p += scnprintf(p, left, "%c", info->params.interface_type[i]);
} else { } else {
p += snprintf(p, left, " "); p += scnprintf(p, left, " ");
} }
} }
if (!strncmp(info->params.interface_type, "ATAPI", 5)) { if (!strncmp(info->params.interface_type, "ATAPI", 5)) {
p += snprintf(p, left, "\tdevice: %u lun: %u\n", p += scnprintf(p, left, "\tdevice: %u lun: %u\n",
info->params.device_path.atapi.device, info->params.device_path.atapi.device,
info->params.device_path.atapi.lun); info->params.device_path.atapi.lun);
} else if (!strncmp(info->params.interface_type, "ATA", 3)) { } else if (!strncmp(info->params.interface_type, "ATA", 3)) {
p += snprintf(p, left, "\tdevice: %u\n", p += scnprintf(p, left, "\tdevice: %u\n",
info->params.device_path.ata.device); info->params.device_path.ata.device);
} else if (!strncmp(info->params.interface_type, "SCSI", 4)) { } else if (!strncmp(info->params.interface_type, "SCSI", 4)) {
p += snprintf(p, left, "\tid: %u lun: %llu\n", p += scnprintf(p, left, "\tid: %u lun: %llu\n",
info->params.device_path.scsi.id, info->params.device_path.scsi.id,
info->params.device_path.scsi.lun); info->params.device_path.scsi.lun);
} else if (!strncmp(info->params.interface_type, "USB", 3)) { } else if (!strncmp(info->params.interface_type, "USB", 3)) {
p += snprintf(p, left, "\tserial_number: %llx\n", p += scnprintf(p, left, "\tserial_number: %llx\n",
info->params.device_path.usb.serial_number); info->params.device_path.usb.serial_number);
} else if (!strncmp(info->params.interface_type, "1394", 4)) { } else if (!strncmp(info->params.interface_type, "1394", 4)) {
p += snprintf(p, left, "\teui: %llx\n", p += scnprintf(p, left, "\teui: %llx\n",
info->params.device_path.i1394.eui); info->params.device_path.i1394.eui);
} else if (!strncmp(info->params.interface_type, "FIBRE", 5)) { } else if (!strncmp(info->params.interface_type, "FIBRE", 5)) {
p += snprintf(p, left, "\twwid: %llx lun: %llx\n", p += scnprintf(p, left, "\twwid: %llx lun: %llx\n",
info->params.device_path.fibre.wwid, info->params.device_path.fibre.wwid,
info->params.device_path.fibre.lun); info->params.device_path.fibre.lun);
} else if (!strncmp(info->params.interface_type, "I2O", 3)) { } else if (!strncmp(info->params.interface_type, "I2O", 3)) {
p += snprintf(p, left, "\tidentity_tag: %llx\n", p += scnprintf(p, left, "\tidentity_tag: %llx\n",
info->params.device_path.i2o.identity_tag); info->params.device_path.i2o.identity_tag);
} else if (!strncmp(info->params.interface_type, "RAID", 4)) { } else if (!strncmp(info->params.interface_type, "RAID", 4)) {
p += snprintf(p, left, "\tidentity_tag: %x\n", p += scnprintf(p, left, "\tidentity_tag: %x\n",
info->params.device_path.raid.array_number); info->params.device_path.raid.array_number);
} else if (!strncmp(info->params.interface_type, "SATA", 4)) { } else if (!strncmp(info->params.interface_type, "SATA", 4)) {
p += snprintf(p, left, "\tdevice: %u\n", p += scnprintf(p, left, "\tdevice: %u\n",
info->params.device_path.sata.device); info->params.device_path.sata.device);
} else { } else {
p += snprintf(p, left, "\tunknown: %llx %llx\n", p += scnprintf(p, left, "\tunknown: %llx %llx\n",
info->params.device_path.unknown.reserved1, info->params.device_path.unknown.reserved1,
info->params.device_path.unknown.reserved2); info->params.device_path.unknown.reserved2);
} }
...@@ -256,7 +256,7 @@ edd_show_version(struct edd_device *edev, char *buf) ...@@ -256,7 +256,7 @@ edd_show_version(struct edd_device *edev, char *buf)
return -EINVAL; return -EINVAL;
} }
p += snprintf(p, left, "0x%02x\n", info->version); p += scnprintf(p, left, "0x%02x\n", info->version);
return (p - buf); return (p - buf);
} }
...@@ -264,7 +264,7 @@ static ssize_t ...@@ -264,7 +264,7 @@ static ssize_t
edd_show_disk80_sig(struct edd_device *edev, char *buf) edd_show_disk80_sig(struct edd_device *edev, char *buf)
{ {
char *p = buf; char *p = buf;
p += snprintf(p, left, "0x%08x\n", edd_disk80_sig); p += scnprintf(p, left, "0x%08x\n", edd_disk80_sig);
return (p - buf); return (p - buf);
} }
...@@ -278,16 +278,16 @@ edd_show_extensions(struct edd_device *edev, char *buf) ...@@ -278,16 +278,16 @@ edd_show_extensions(struct edd_device *edev, char *buf)
} }
if (info->interface_support & EDD_EXT_FIXED_DISK_ACCESS) { if (info->interface_support & EDD_EXT_FIXED_DISK_ACCESS) {
p += snprintf(p, left, "Fixed disk access\n"); p += scnprintf(p, left, "Fixed disk access\n");
} }
if (info->interface_support & EDD_EXT_DEVICE_LOCKING_AND_EJECTING) { if (info->interface_support & EDD_EXT_DEVICE_LOCKING_AND_EJECTING) {
p += snprintf(p, left, "Device locking and ejecting\n"); p += scnprintf(p, left, "Device locking and ejecting\n");
} }
if (info->interface_support & EDD_EXT_ENHANCED_DISK_DRIVE_SUPPORT) { if (info->interface_support & EDD_EXT_ENHANCED_DISK_DRIVE_SUPPORT) {
p += snprintf(p, left, "Enhanced Disk Drive support\n"); p += scnprintf(p, left, "Enhanced Disk Drive support\n");
} }
if (info->interface_support & EDD_EXT_64BIT_EXTENSIONS) { if (info->interface_support & EDD_EXT_64BIT_EXTENSIONS) {
p += snprintf(p, left, "64-bit extensions\n"); p += scnprintf(p, left, "64-bit extensions\n");
} }
return (p - buf); return (p - buf);
} }
...@@ -302,21 +302,21 @@ edd_show_info_flags(struct edd_device *edev, char *buf) ...@@ -302,21 +302,21 @@ edd_show_info_flags(struct edd_device *edev, char *buf)
} }
if (info->params.info_flags & EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT) if (info->params.info_flags & EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT)
p += snprintf(p, left, "DMA boundary error transparent\n"); p += scnprintf(p, left, "DMA boundary error transparent\n");
if (info->params.info_flags & EDD_INFO_GEOMETRY_VALID) if (info->params.info_flags & EDD_INFO_GEOMETRY_VALID)
p += snprintf(p, left, "geometry valid\n"); p += scnprintf(p, left, "geometry valid\n");
if (info->params.info_flags & EDD_INFO_REMOVABLE) if (info->params.info_flags & EDD_INFO_REMOVABLE)
p += snprintf(p, left, "removable\n"); p += scnprintf(p, left, "removable\n");
if (info->params.info_flags & EDD_INFO_WRITE_VERIFY) if (info->params.info_flags & EDD_INFO_WRITE_VERIFY)
p += snprintf(p, left, "write verify\n"); p += scnprintf(p, left, "write verify\n");
if (info->params.info_flags & EDD_INFO_MEDIA_CHANGE_NOTIFICATION) if (info->params.info_flags & EDD_INFO_MEDIA_CHANGE_NOTIFICATION)
p += snprintf(p, left, "media change notification\n"); p += scnprintf(p, left, "media change notification\n");
if (info->params.info_flags & EDD_INFO_LOCKABLE) if (info->params.info_flags & EDD_INFO_LOCKABLE)
p += snprintf(p, left, "lockable\n"); p += scnprintf(p, left, "lockable\n");
if (info->params.info_flags & EDD_INFO_NO_MEDIA_PRESENT) if (info->params.info_flags & EDD_INFO_NO_MEDIA_PRESENT)
p += snprintf(p, left, "no media present\n"); p += scnprintf(p, left, "no media present\n");
if (info->params.info_flags & EDD_INFO_USE_INT13_FN50) if (info->params.info_flags & EDD_INFO_USE_INT13_FN50)
p += snprintf(p, left, "use int13 fn50\n"); p += scnprintf(p, left, "use int13 fn50\n");
return (p - buf); return (p - buf);
} }
...@@ -329,7 +329,7 @@ edd_show_default_cylinders(struct edd_device *edev, char *buf) ...@@ -329,7 +329,7 @@ edd_show_default_cylinders(struct edd_device *edev, char *buf)
return -EINVAL; return -EINVAL;
} }
p += snprintf(p, left, "0x%x\n", info->params.num_default_cylinders); p += scnprintf(p, left, "0x%x\n", info->params.num_default_cylinders);
return (p - buf); return (p - buf);
} }
...@@ -342,7 +342,7 @@ edd_show_default_heads(struct edd_device *edev, char *buf) ...@@ -342,7 +342,7 @@ edd_show_default_heads(struct edd_device *edev, char *buf)
return -EINVAL; return -EINVAL;
} }
p += snprintf(p, left, "0x%x\n", info->params.num_default_heads); p += scnprintf(p, left, "0x%x\n", info->params.num_default_heads);
return (p - buf); return (p - buf);
} }
...@@ -355,7 +355,7 @@ edd_show_default_sectors_per_track(struct edd_device *edev, char *buf) ...@@ -355,7 +355,7 @@ edd_show_default_sectors_per_track(struct edd_device *edev, char *buf)
return -EINVAL; return -EINVAL;
} }
p += snprintf(p, left, "0x%x\n", info->params.sectors_per_track); p += scnprintf(p, left, "0x%x\n", info->params.sectors_per_track);
return (p - buf); return (p - buf);
} }
...@@ -368,7 +368,7 @@ edd_show_sectors(struct edd_device *edev, char *buf) ...@@ -368,7 +368,7 @@ edd_show_sectors(struct edd_device *edev, char *buf)
return -EINVAL; return -EINVAL;
} }
p += snprintf(p, left, "0x%llx\n", info->params.number_of_sectors); p += scnprintf(p, left, "0x%llx\n", info->params.number_of_sectors);
return (p - buf); return (p - buf);
} }
......
...@@ -134,7 +134,7 @@ static int lparcfg_data(unsigned char *buf, unsigned long size) ...@@ -134,7 +134,7 @@ static int lparcfg_data(unsigned char *buf, unsigned long size)
memset(buf, 0, size); memset(buf, 0, size);
shared = (int)(lpaca->xLpPacaPtr->xSharedProc); shared = (int)(lpaca->xLpPacaPtr->xSharedProc);
n += snprintf(buf, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf, LPARCFG_BUFF_SIZE - n,
"serial_number=%c%c%c%c%c%c%c\n", "serial_number=%c%c%c%c%c%c%c\n",
e2a(xItExtVpdPanel.mfgID[2]), e2a(xItExtVpdPanel.mfgID[2]),
e2a(xItExtVpdPanel.mfgID[3]), e2a(xItExtVpdPanel.mfgID[3]),
...@@ -144,7 +144,7 @@ static int lparcfg_data(unsigned char *buf, unsigned long size) ...@@ -144,7 +144,7 @@ static int lparcfg_data(unsigned char *buf, unsigned long size)
e2a(xItExtVpdPanel.systemSerial[4]), e2a(xItExtVpdPanel.systemSerial[4]),
e2a(xItExtVpdPanel.systemSerial[5])); e2a(xItExtVpdPanel.systemSerial[5]));
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_type=%c%c%c%c\n", "system_type=%c%c%c%c\n",
e2a(xItExtVpdPanel.machineType[0]), e2a(xItExtVpdPanel.machineType[0]),
e2a(xItExtVpdPanel.machineType[1]), e2a(xItExtVpdPanel.machineType[1]),
...@@ -152,23 +152,23 @@ static int lparcfg_data(unsigned char *buf, unsigned long size) ...@@ -152,23 +152,23 @@ static int lparcfg_data(unsigned char *buf, unsigned long size)
e2a(xItExtVpdPanel.machineType[3])); e2a(xItExtVpdPanel.machineType[3]));
lp_index = HvLpConfig_getLpIndex(); lp_index = HvLpConfig_getLpIndex();
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_id=%d\n", (int)lp_index); "partition_id=%d\n", (int)lp_index);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_active_processors=%d\n", "system_active_processors=%d\n",
(int)HvLpConfig_getSystemPhysicalProcessors()); (int)HvLpConfig_getSystemPhysicalProcessors());
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_potential_processors=%d\n", "system_potential_processors=%d\n",
(int)HvLpConfig_getSystemPhysicalProcessors()); (int)HvLpConfig_getSystemPhysicalProcessors());
processors = (int)HvLpConfig_getPhysicalProcessors(); processors = (int)HvLpConfig_getPhysicalProcessors();
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_active_processors=%d\n", processors); "partition_active_processors=%d\n", processors);
max_processors = (int)HvLpConfig_getMaxPhysicalProcessors(); max_processors = (int)HvLpConfig_getMaxPhysicalProcessors();
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_potential_processors=%d\n", max_processors); "partition_potential_processors=%d\n", max_processors);
if(shared) { if(shared) {
...@@ -178,22 +178,22 @@ static int lparcfg_data(unsigned char *buf, unsigned long size) ...@@ -178,22 +178,22 @@ static int lparcfg_data(unsigned char *buf, unsigned long size)
entitled_capacity = processors * 100; entitled_capacity = processors * 100;
max_entitled_capacity = max_processors * 100; max_entitled_capacity = max_processors * 100;
} }
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_entitled_capacity=%d\n", entitled_capacity); "partition_entitled_capacity=%d\n", entitled_capacity);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_max_entitled_capacity=%d\n", "partition_max_entitled_capacity=%d\n",
max_entitled_capacity); max_entitled_capacity);
if(shared) { if(shared) {
pool_id = HvLpConfig_getSharedPoolIndex(); pool_id = HvLpConfig_getSharedPoolIndex();
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool=%d\n", n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool=%d\n",
(int)pool_id); (int)pool_id);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"pool_capacity=%d\n", (int)(HvLpConfig_getNumProcsInSharedPool(pool_id)*100)); "pool_capacity=%d\n", (int)(HvLpConfig_getNumProcsInSharedPool(pool_id)*100));
} }
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"shared_processor_mode=%d\n", shared); "shared_processor_mode=%d\n", shared);
return 0; return 0;
...@@ -297,13 +297,13 @@ static int lparcfg_data(unsigned char *buf, unsigned long size) ...@@ -297,13 +297,13 @@ static int lparcfg_data(unsigned char *buf, unsigned long size)
if(lp_index_ptr) lp_index = *lp_index_ptr; if(lp_index_ptr) lp_index = *lp_index_ptr;
} }
n = snprintf(buf, LPARCFG_BUFF_SIZE - n, n = scnprintf(buf, LPARCFG_BUFF_SIZE - n,
"serial_number=%s\n", system_id); "serial_number=%s\n", system_id);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_type=%s\n", model); "system_type=%s\n", model);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_id=%d\n", (int)lp_index); "partition_id=%d\n", (int)lp_index);
rtas_node = find_path_device("/rtas"); rtas_node = find_path_device("/rtas");
...@@ -317,74 +317,74 @@ static int lparcfg_data(unsigned char *buf, unsigned long size) ...@@ -317,74 +317,74 @@ static int lparcfg_data(unsigned char *buf, unsigned long size)
if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
h_get_ppp(&h_entitled,&h_unallocated,&h_aggregation,&h_resource); h_get_ppp(&h_entitled,&h_unallocated,&h_aggregation,&h_resource);
#ifdef DEBUG #ifdef DEBUG
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"R4=0x%lx\n", h_entitled); "R4=0x%lx\n", h_entitled);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"R5=0x%lx\n", h_unallocated); "R5=0x%lx\n", h_unallocated);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"R6=0x%lx\n", h_aggregation); "R6=0x%lx\n", h_aggregation);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"R7=0x%lx\n", h_resource); "R7=0x%lx\n", h_resource);
#endif /* DEBUG */ #endif /* DEBUG */
} }
if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
system_potential_processors = get_splpar_potential_characteristics(); system_potential_processors = get_splpar_potential_characteristics();
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_active_processors=%ld\n", "system_active_processors=%ld\n",
(h_resource >> 2*8) & 0xffff); (h_resource >> 2*8) & 0xffff);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_potential_processors=%d\n", "system_potential_processors=%d\n",
system_potential_processors); system_potential_processors);
} else { } else {
system_potential_processors = system_active_processors; system_potential_processors = system_active_processors;
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_active_processors=%d\n", "system_active_processors=%d\n",
system_active_processors); system_active_processors);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"system_potential_processors=%d\n", "system_potential_processors=%d\n",
system_potential_processors); system_potential_processors);
} }
processors = systemcfg->processorCount; processors = systemcfg->processorCount;
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_active_processors=%d\n", processors); "partition_active_processors=%d\n", processors);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_potential_processors=%d\n", "partition_potential_processors=%d\n",
system_active_processors); system_active_processors);
/* max_entitled_capacity will come out of get_splpar_potential_characteristics() when that function is complete */ /* max_entitled_capacity will come out of get_splpar_potential_characteristics() when that function is complete */
max_entitled_capacity = system_active_processors * 100; max_entitled_capacity = system_active_processors * 100;
if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_entitled_capacity=%ld\n", h_entitled); "partition_entitled_capacity=%ld\n", h_entitled);
} else { } else {
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_entitled_capacity=%d\n", system_active_processors*100); "partition_entitled_capacity=%d\n", system_active_processors*100);
} }
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"partition_max_entitled_capacity=%d\n", "partition_max_entitled_capacity=%d\n",
max_entitled_capacity); max_entitled_capacity);
shared = 0; shared = 0;
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"shared_processor_mode=%d\n", shared); "shared_processor_mode=%d\n", shared);
if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"pool=%ld\n", (h_aggregation >> 0*8)&0xffff); "pool=%ld\n", (h_aggregation >> 0*8)&0xffff);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"pool_capacity=%ld\n", (h_resource >> 3*8) &0xffff); "pool_capacity=%ld\n", (h_resource >> 3*8) &0xffff);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"group=%ld\n", (h_aggregation >> 2*8)&0xffff); "group=%ld\n", (h_aggregation >> 2*8)&0xffff);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"capped=%ld\n", (h_resource >> 6*8)&0x40); "capped=%ld\n", (h_resource >> 6*8)&0x40);
n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n,
"capacity_weight=%d\n", (int)(h_resource>>5*8)&0xFF); "capacity_weight=%d\n", (int)(h_resource>>5*8)&0xFF);
} }
return 0; return 0;
......
...@@ -287,9 +287,9 @@ static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf, ...@@ -287,9 +287,9 @@ static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf,
char stkbuf[40]; /* its small, its on stack */ char stkbuf[40]; /* its small, its on stack */
int n, sn; int n, sn;
if (power_on_time == 0) if (power_on_time == 0)
n = snprintf(stkbuf, 40, "Power on time not set\n"); n = scnprintf(stkbuf,sizeof(stkbuf),"Power on time not set\n");
else else
n = snprintf(stkbuf, 40, "%lu\n", power_on_time); n = scnprintf(stkbuf,sizeof(stkbuf),"%lu\n",power_on_time);
sn = strlen (stkbuf) +1; sn = strlen (stkbuf) +1;
if (*ppos >= sn) if (*ppos >= sn)
...@@ -410,9 +410,10 @@ static ssize_t ppc_rtas_clock_read(struct file * file, char * buf, ...@@ -410,9 +410,10 @@ static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
if (error != 0){ if (error != 0){
printk(KERN_WARNING "error: reading the clock returned: %s\n", printk(KERN_WARNING "error: reading the clock returned: %s\n",
ppc_rtas_process_error(error)); ppc_rtas_process_error(error));
n = snprintf (stkbuf, 40, "0"); n = scnprintf (stkbuf, sizeof(stkbuf), "0");
} else { } else {
n = snprintf (stkbuf, 40, "%lu\n", mktime(year, mon, day, hour, min, sec)); n = scnprintf (stkbuf, sizeof(stkbuf), "%lu\n",
mktime(year, mon, day, hour, min, sec));
} }
kfree(ret); kfree(ret);
...@@ -819,7 +820,7 @@ int get_location_code(struct individual_sensor s, char * buffer) ...@@ -819,7 +820,7 @@ int get_location_code(struct individual_sensor s, char * buffer)
n += check_location_string(ret, buffer + n); n += check_location_string(ret, buffer + n);
n += sprintf ( buffer+n, " "); n += sprintf ( buffer+n, " ");
/* see how many characters we have printed */ /* see how many characters we have printed */
snprintf ( t, 50, "%s ", ret); scnprintf(t, sizeof(t), "%s ", ret);
pos += strlen(t); pos += strlen(t);
if (pos >= llen) pos=0; if (pos >= llen) pos=0;
...@@ -863,7 +864,7 @@ static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf, ...@@ -863,7 +864,7 @@ static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf,
int n, sn; int n, sn;
char stkbuf[40]; /* its small, its on stack */ char stkbuf[40]; /* its small, its on stack */
n = snprintf(stkbuf, 40, "%lu\n", rtas_tone_frequency); n = scnprintf(stkbuf, 40, "%lu\n", rtas_tone_frequency);
sn = strlen (stkbuf) +1; sn = strlen (stkbuf) +1;
if (*ppos >= sn) if (*ppos >= sn)
...@@ -917,7 +918,7 @@ static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf, ...@@ -917,7 +918,7 @@ static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
int n, sn; int n, sn;
char stkbuf[40]; /* its small, its on stack */ char stkbuf[40]; /* its small, its on stack */
n = snprintf(stkbuf, 40, "%lu\n", rtas_tone_volume); n = scnprintf(stkbuf, 40, "%lu\n", rtas_tone_volume);
sn = strlen (stkbuf) +1; sn = strlen (stkbuf) +1;
if (*ppos >= sn) if (*ppos >= sn)
......
...@@ -39,7 +39,7 @@ prom_printf(char *fmt, ...) ...@@ -39,7 +39,7 @@ prom_printf(char *fmt, ...)
int i; int i;
va_start(args, fmt); va_start(args, fmt);
i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args); i = vscnprintf(ppbuf, sizeof(ppbuf), fmt, args);
va_end(args); va_end(args);
prom_write(ppbuf, i); prom_write(ppbuf, i);
......
...@@ -40,7 +40,7 @@ prom_printf(char *fmt, ...) ...@@ -40,7 +40,7 @@ prom_printf(char *fmt, ...)
int i; int i;
va_start(args, fmt); va_start(args, fmt);
i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args); i = vscnprintf(ppbuf, sizeof(ppbuf), fmt, args);
va_end(args); va_end(args);
prom_write(ppbuf, i); prom_write(ppbuf, i);
......
...@@ -164,7 +164,7 @@ void early_printk(const char *fmt, ...) ...@@ -164,7 +164,7 @@ void early_printk(const char *fmt, ...)
va_list ap; va_list ap;
va_start(ap,fmt); va_start(ap,fmt);
n = vsnprintf(buf,512,fmt,ap); n = vscnprintf(buf,512,fmt,ap);
early_console->write(early_console,buf,n); early_console->write(early_console,buf,n);
va_end(ap); va_end(ap);
} }
......
...@@ -52,7 +52,7 @@ show_pools (struct device *dev, char *buf) ...@@ -52,7 +52,7 @@ show_pools (struct device *dev, char *buf)
next = buf; next = buf;
size = PAGE_SIZE; size = PAGE_SIZE;
temp = snprintf (next, size, "poolinfo - 0.1\n"); temp = scnprintf(next, size, "poolinfo - 0.1\n");
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -67,7 +67,7 @@ show_pools (struct device *dev, char *buf) ...@@ -67,7 +67,7 @@ show_pools (struct device *dev, char *buf)
} }
/* per-pool info, no real statistics yet */ /* per-pool info, no real statistics yet */
temp = snprintf (next, size, "%-16s %4u %4Zu %4Zu %2u\n", temp = scnprintf(next, size, "%-16s %4u %4Zu %4Zu %2u\n",
pool->name, pool->name,
blocks, pages * pool->blocks_per_page, blocks, pages * pool->blocks_per_page,
pool->size, pages); pool->size, pages);
......
...@@ -259,7 +259,7 @@ sn_debug_printf(const char *fmt, ...) ...@@ -259,7 +259,7 @@ sn_debug_printf(const char *fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
printed_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args); printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
early_printk_sn_sal(printk_buf, printed_len); early_printk_sn_sal(printk_buf, printed_len);
va_end(args); va_end(args);
return printed_len; return printed_len;
......
...@@ -149,7 +149,7 @@ void hvlog(char *fmt, ...) ...@@ -149,7 +149,7 @@ void hvlog(char *fmt, ...)
spin_lock_irqsave(&consoleloglock, flags); spin_lock_irqsave(&consoleloglock, flags);
va_start(args, fmt); va_start(args, fmt);
i = vsnprintf(buf, sizeof(buf) - 1, fmt, args); i = vscnprintf(buf, sizeof(buf) - 1, fmt, args);
va_end(args); va_end(args);
buf[i++] = '\r'; buf[i++] = '\r';
HvCall_writeLogBuffer(buf, i); HvCall_writeLogBuffer(buf, i);
......
...@@ -198,7 +198,7 @@ static ssize_t show_scaling_governor (struct cpufreq_policy * policy, char *buf) ...@@ -198,7 +198,7 @@ static ssize_t show_scaling_governor (struct cpufreq_policy * policy, char *buf)
else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE)
return sprintf(buf, "performance\n"); return sprintf(buf, "performance\n");
else if (policy->governor) else if (policy->governor)
return snprintf(buf, CPUFREQ_NAME_LEN, "%s\n", policy->governor->name); return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", policy->governor->name);
return -EINVAL; return -EINVAL;
} }
...@@ -234,7 +234,7 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, ...@@ -234,7 +234,7 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy,
*/ */
static ssize_t show_scaling_driver (struct cpufreq_policy * policy, char *buf) static ssize_t show_scaling_driver (struct cpufreq_policy * policy, char *buf)
{ {
return snprintf(buf, CPUFREQ_NAME_LEN, "%s\n", cpufreq_driver->name); return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", cpufreq_driver->name);
} }
/** /**
...@@ -254,7 +254,7 @@ static ssize_t show_scaling_available_governors (struct cpufreq_policy * policy, ...@@ -254,7 +254,7 @@ static ssize_t show_scaling_available_governors (struct cpufreq_policy * policy,
list_for_each_entry(t, &cpufreq_governor_list, governor_list) { list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) - (CPUFREQ_NAME_LEN + 2))) if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) - (CPUFREQ_NAME_LEN + 2)))
goto out; goto out;
i += snprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name); i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name);
} }
out: out:
i += sprintf(&buf[i], "\n"); i += sprintf(&buf[i], "\n");
......
...@@ -139,7 +139,7 @@ static int cpufreq_proc_read ( ...@@ -139,7 +139,7 @@ static int cpufreq_proc_read (
break; break;
} }
} else } else
p += snprintf(p, CPUFREQ_NAME_LEN, "%s\n", policy.governor->name); p += scnprintf(p, CPUFREQ_NAME_LEN, "%s\n", policy.governor->name);
} }
end: end:
len = (p - page); len = (p - page);
......
...@@ -195,12 +195,12 @@ static int stripe_status(struct dm_target *ti, ...@@ -195,12 +195,12 @@ static int stripe_status(struct dm_target *ti,
break; break;
case STATUSTYPE_TABLE: case STATUSTYPE_TABLE:
offset = snprintf(result, maxlen, "%d " SECTOR_FORMAT, offset = scnprintf(result, maxlen, "%d " SECTOR_FORMAT,
sc->stripes, sc->chunk_mask + 1); sc->stripes, sc->chunk_mask + 1);
for (i = 0; i < sc->stripes; i++) { for (i = 0; i < sc->stripes; i++) {
format_dev_t(buffer, sc->stripe[i].dev->bdev->bd_dev); format_dev_t(buffer, sc->stripe[i].dev->bdev->bd_dev);
offset += offset +=
snprintf(result + offset, maxlen - offset, scnprintf(result + offset, maxlen - offset,
" %s " SECTOR_FORMAT, buffer, " %s " SECTOR_FORMAT, buffer,
sc->stripe[i].physical_start); sc->stripe[i].physical_start);
} }
......
...@@ -392,15 +392,15 @@ videocodec_build_table (void) ...@@ -392,15 +392,15 @@ videocodec_build_table (void)
videocodec_buf = (char *) kmalloc(size, GFP_KERNEL); videocodec_buf = (char *) kmalloc(size, GFP_KERNEL);
i = 0; i = 0;
i += snprintf(videocodec_buf + i, size - 1, i += scnprintf(videocodec_buf + i, size - 1,
"<S>lave or attached <M>aster name type flags magic "); "<S>lave or attached <M>aster name type flags magic ");
i += snprintf(videocodec_buf + i, size - 1, "(connected as)\n"); i += scnprintf(videocodec_buf + i, size -i - 1, "(connected as)\n");
h = codeclist_top; h = codeclist_top;
while (h) { while (h) {
if (i > (size - LINESIZE)) if (i > (size - LINESIZE))
break; // security check break; // security check
i += snprintf(videocodec_buf + i, size, i += scnprintf(videocodec_buf + i, size -i -1,
"S %32s %04x %08lx %08lx (TEMPLATE)\n", "S %32s %04x %08lx %08lx (TEMPLATE)\n",
h->codec->name, h->codec->type, h->codec->name, h->codec->type,
h->codec->flags, h->codec->magic); h->codec->flags, h->codec->magic);
...@@ -408,7 +408,7 @@ videocodec_build_table (void) ...@@ -408,7 +408,7 @@ videocodec_build_table (void)
while (a) { while (a) {
if (i > (size - LINESIZE)) if (i > (size - LINESIZE))
break; // security check break; // security check
i += snprintf(videocodec_buf + i, size, i += scnprintf(videocodec_buf + i, size -i -1,
"M %32s %04x %08lx %08lx (%s)\n", "M %32s %04x %08lx %08lx (%s)\n",
a->codec->master_data->name, a->codec->master_data->name,
a->codec->master_data->type, a->codec->master_data->type,
......
...@@ -2058,30 +2058,30 @@ static int MUNICH_minden(struct net_device *dev, char *page) ...@@ -2058,30 +2058,30 @@ static int MUNICH_minden(struct net_device *dev, char *page)
{ {
frs0 = readb(lbi + FRS0); frs0 = readb(lbi + FRS0);
fmr2 = readb(lbi + FMR2); fmr2 = readb(lbi + FMR2);
len += snprintf(page + len, PAGE_SIZE - len, "Controller status:\n"); len += scnprintf(page + len, PAGE_SIZE - len, "Controller status:\n");
if (frs0 == 0) if (frs0 == 0)
len += snprintf(page + len, PAGE_SIZE - len, "\tNo alarms\n"); len += scnprintf(page + len, PAGE_SIZE - len, "\tNo alarms\n");
else else
{ {
if (frs0 & FRS0_LOS) if (frs0 & FRS0_LOS)
len += snprintf(page + len, PAGE_SIZE - len, "\tLoss Of Signal\n"); len += scnprintf(page + len, PAGE_SIZE - len, "\tLoss Of Signal\n");
else else
{ {
if (frs0 & FRS0_AIS) if (frs0 & FRS0_AIS)
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tAlarm Indication Signal\n"); "\tAlarm Indication Signal\n");
else else
{ {
if (frs0 & FRS0_AUXP) if (frs0 & FRS0_AUXP)
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tAuxiliary Pattern Indication\n"); "\tAuxiliary Pattern Indication\n");
if (frs0 & FRS0_LFA) if (frs0 & FRS0_LFA)
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tLoss of Frame Alignment\n"); "\tLoss of Frame Alignment\n");
else else
{ {
if (frs0 & FRS0_RRA) if (frs0 & FRS0_RRA)
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tReceive Remote Alarm\n"); "\tReceive Remote Alarm\n");
/* You can't set this framing with the /proc interface, but it */ /* You can't set this framing with the /proc interface, but it */
...@@ -2089,11 +2089,11 @@ static int MUNICH_minden(struct net_device *dev, char *page) ...@@ -2089,11 +2089,11 @@ static int MUNICH_minden(struct net_device *dev, char *page)
if ((board->framing == SLICECOM_FRAMING_CRC4) && if ((board->framing == SLICECOM_FRAMING_CRC4) &&
(frs0 & FRS0_LMFA)) (frs0 & FRS0_LMFA))
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tLoss of CRC4 Multiframe Alignment\n"); "\tLoss of CRC4 Multiframe Alignment\n");
if (((fmr2 & 0xc0) == 0xc0) && (frs0 & FRS0_NMF)) if (((fmr2 & 0xc0) == 0xc0) && (frs0 & FRS0_NMF))
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tNo CRC4 Multiframe alignment Found after 400 msec\n"); "\tNo CRC4 Multiframe alignment Found after 400 msec\n");
} }
} }
...@@ -2102,27 +2102,27 @@ static int MUNICH_minden(struct net_device *dev, char *page) ...@@ -2102,27 +2102,27 @@ static int MUNICH_minden(struct net_device *dev, char *page)
frs1 = readb(lbi + FRS1); frs1 = readb(lbi + FRS1);
if (FRS1_XLS & frs1) if (FRS1_XLS & frs1)
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tTransmit Line Short\n"); "\tTransmit Line Short\n");
/* debug Rx ring: DEL: - vagy meghagyni, de akkor legyen kicsit altalanosabb */ /* debug Rx ring: DEL: - vagy meghagyni, de akkor legyen kicsit altalanosabb */
} }
len += snprintf(page + len, PAGE_SIZE - len, "Rx ring:\n"); len += scnprintf(page + len, PAGE_SIZE - len, "Rx ring:\n");
len += snprintf(page + len, PAGE_SIZE - len, "\trafutott: %d\n", hw->rafutott); len += scnprintf(page + len, PAGE_SIZE - len, "\trafutott: %d\n", hw->rafutott);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"\tlastcheck: %ld, jiffies: %ld\n", board->lastcheck, jiffies); "\tlastcheck: %ld, jiffies: %ld\n", board->lastcheck, jiffies);
len += snprintf(page + len, PAGE_SIZE - len, "\tbase: %08x\n", len += scnprintf(page + len, PAGE_SIZE - len, "\tbase: %08x\n",
(u32) virt_to_phys(&hw->rx_desc[0])); (u32) virt_to_phys(&hw->rx_desc[0]));
len += snprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %d\n", len += scnprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %d\n",
hw->rx_desc_ptr); hw->rx_desc_ptr);
len += snprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %08x\n", len += scnprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %08x\n",
(u32) virt_to_phys(&hw->rx_desc[hw->rx_desc_ptr])); (u32) virt_to_phys(&hw->rx_desc[hw->rx_desc_ptr]));
len += snprintf(page + len, PAGE_SIZE - len, "\thw_curr_ptr: %08x\n", len += scnprintf(page + len, PAGE_SIZE - len, "\thw_curr_ptr: %08x\n",
board->ccb->current_rx_desc[hw->channel]); board->ccb->current_rx_desc[hw->channel]);
for (i = 0; i < RX_DESC_MAX; i++) for (i = 0; i < RX_DESC_MAX; i++)
len += snprintf(page + len, PAGE_SIZE - len, "\t%08x %08x %08x %08x\n", len += scnprintf(page + len, PAGE_SIZE - len, "\t%08x %08x %08x %08x\n",
*((u32 *) & hw->rx_desc[i] + 0), *((u32 *) & hw->rx_desc[i] + 0),
*((u32 *) & hw->rx_desc[i] + 1), *((u32 *) & hw->rx_desc[i] + 1),
*((u32 *) & hw->rx_desc[i] + 2), *((u32 *) & hw->rx_desc[i] + 2),
...@@ -2130,7 +2130,7 @@ static int MUNICH_minden(struct net_device *dev, char *page) ...@@ -2130,7 +2130,7 @@ static int MUNICH_minden(struct net_device *dev, char *page)
if (!board->isx21) if (!board->isx21)
{ {
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"Interfaces using this board: (channel-group, interface, timeslots)\n"); "Interfaces using this board: (channel-group, interface, timeslots)\n");
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{ {
...@@ -2141,26 +2141,26 @@ static int MUNICH_minden(struct net_device *dev, char *page) ...@@ -2141,26 +2141,26 @@ static int MUNICH_minden(struct net_device *dev, char *page)
((struct slicecom_privdata *)((struct comx_channel *)devp-> ((struct slicecom_privdata *)((struct comx_channel *)devp->
priv)->HW_privdata)-> priv)->HW_privdata)->
timeslots; timeslots;
len += snprintf(page + len, PAGE_SIZE - len, "\t%2d %s: ", i, len += scnprintf(page + len, PAGE_SIZE - len, "\t%2d %s: ", i,
devp->name); devp->name);
for (j = 0; j < 32; j++) for (j = 0; j < 32; j++)
if ((1 << j) & timeslots) if ((1 << j) & timeslots)
len += snprintf(page + len, PAGE_SIZE - len, "%d ", j); len += scnprintf(page + len, PAGE_SIZE - len, "%d ", j);
len += snprintf(page + len, PAGE_SIZE - len, "\n"); len += scnprintf(page + len, PAGE_SIZE - len, "\n");
} }
} }
} }
len += snprintf(page + len, PAGE_SIZE - len, "Interrupt work histogram:\n"); len += scnprintf(page + len, PAGE_SIZE - len, "Interrupt work histogram:\n");
for (i = 0; i < MAX_WORK; i++) for (i = 0; i < MAX_WORK; i++)
len += snprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i, len += scnprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i,
board->histogram[i], (i && board->histogram[i], (i &&
((i + 1) % 4 == 0 || ((i + 1) % 4 == 0 ||
i == MAX_WORK - 1)) ? '\n' : ' '); i == MAX_WORK - 1)) ? '\n' : ' ');
len += snprintf(page + len, PAGE_SIZE - len, "Tx ring histogram:\n"); len += scnprintf(page + len, PAGE_SIZE - len, "Tx ring histogram:\n");
for (i = 0; i < TX_DESC_MAX; i++) for (i = 0; i < TX_DESC_MAX; i++)
len += snprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i, len += scnprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i,
hw->tx_ring_hist[i], (i && hw->tx_ring_hist[i], (i &&
((i + 1) % 4 == 0 || ((i + 1) % 4 == 0 ||
i == i ==
...@@ -2196,72 +2196,72 @@ static int MUNICH_minden(struct net_device *dev, char *page) ...@@ -2196,72 +2196,72 @@ static int MUNICH_minden(struct net_device *dev, char *page)
sump[j] += p[j]; sump[j] += p[j];
} }
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"Data in current interval (%d seconds elapsed):\n", "Data in current interval (%d seconds elapsed):\n",
board->elapsed_seconds); board->elapsed_seconds);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n", " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
curr_int->line_code_violations, curr_int->line_code_violations,
curr_int->path_code_violations, curr_int->e_bit_errors); curr_int->path_code_violations, curr_int->e_bit_errors);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n", " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
curr_int->slip_secs, curr_int->fr_loss_secs, curr_int->slip_secs, curr_int->fr_loss_secs,
curr_int->line_err_secs, curr_int->degraded_mins); curr_int->line_err_secs, curr_int->degraded_mins);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n", " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
curr_int->errored_secs, curr_int->bursty_err_secs, curr_int->errored_secs, curr_int->bursty_err_secs,
curr_int->severely_err_secs, curr_int->unavail_secs); curr_int->severely_err_secs, curr_int->unavail_secs);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"Data in Interval 1 (15 minutes):\n"); "Data in Interval 1 (15 minutes):\n");
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n", " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
prev_int->line_code_violations, prev_int->line_code_violations,
prev_int->path_code_violations, prev_int->e_bit_errors); prev_int->path_code_violations, prev_int->e_bit_errors);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n", " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
prev_int->slip_secs, prev_int->fr_loss_secs, prev_int->slip_secs, prev_int->fr_loss_secs,
prev_int->line_err_secs, prev_int->degraded_mins); prev_int->line_err_secs, prev_int->degraded_mins);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n", " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
prev_int->errored_secs, prev_int->bursty_err_secs, prev_int->errored_secs, prev_int->bursty_err_secs,
prev_int->severely_err_secs, prev_int->unavail_secs); prev_int->severely_err_secs, prev_int->unavail_secs);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"Data in last 4 intervals (1 hour):\n"); "Data in last 4 intervals (1 hour):\n");
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n", " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
last4.line_code_violations, last4.path_code_violations, last4.line_code_violations, last4.path_code_violations,
last4.e_bit_errors); last4.e_bit_errors);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n", " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
last4.slip_secs, last4.fr_loss_secs, last4.line_err_secs, last4.slip_secs, last4.fr_loss_secs, last4.line_err_secs,
last4.degraded_mins); last4.degraded_mins);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n", " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
last4.errored_secs, last4.bursty_err_secs, last4.errored_secs, last4.bursty_err_secs,
last4.severely_err_secs, last4.unavail_secs); last4.severely_err_secs, last4.unavail_secs);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"Data in last 96 intervals (24 hours):\n"); "Data in last 96 intervals (24 hours):\n");
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n", " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
last96.line_code_violations, last96.path_code_violations, last96.line_code_violations, last96.path_code_violations,
last96.e_bit_errors); last96.e_bit_errors);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n", " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
last96.slip_secs, last96.fr_loss_secs, last96.slip_secs, last96.fr_loss_secs,
last96.line_err_secs, last96.degraded_mins); last96.line_err_secs, last96.degraded_mins);
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
" %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n", " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
last96.errored_secs, last96.bursty_err_secs, last96.errored_secs, last96.bursty_err_secs,
last96.severely_err_secs, last96.unavail_secs); last96.severely_err_secs, last96.unavail_secs);
} }
// len +=snprintf( page + len, PAGE_SIZE - len, "Special events:\n" ); // len +=scnprintf( page + len, PAGE_SIZE - len, "Special events:\n" );
// len +=snprintf( page + len, PAGE_SIZE - len, "\tstat_pri/missed: %u / %u\n", board->stat_pri_races, board->stat_pri_races_missed ); // len +=scnprintf( page + len, PAGE_SIZE - len, "\tstat_pri/missed: %u / %u\n", board->stat_pri_races, board->stat_pri_races_missed );
// len +=snprintf( page + len, PAGE_SIZE - len, "\tstat_pti/missed: %u / %u\n", board->stat_pti_races, board->stat_pti_races_missed ); // len +=scnprintf( page + len, PAGE_SIZE - len, "\tstat_pti/missed: %u / %u\n", board->stat_pti_races, board->stat_pti_races_missed );
return len; return len;
} }
...@@ -2305,8 +2305,8 @@ static int munich_read_proc(char *page, char **start, off_t off, int count, ...@@ -2305,8 +2305,8 @@ static int munich_read_proc(char *page, char **start, off_t off, int count,
{ {
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
if ((1 << i) & timeslots) if ((1 << i) & timeslots)
len += snprintf(page + len, PAGE_SIZE - len, "%d ", i); len += scnprintf(page + len, PAGE_SIZE - len, "%d ", i);
len += snprintf(page + len, PAGE_SIZE - len, "\n"); len += scnprintf(page + len, PAGE_SIZE - len, "\n");
} }
else if (!strcmp(file->name, FILENAME_FRAMING)) else if (!strcmp(file->name, FILENAME_FRAMING))
{ {
...@@ -2314,7 +2314,7 @@ static int munich_read_proc(char *page, char **start, off_t off, int count, ...@@ -2314,7 +2314,7 @@ static int munich_read_proc(char *page, char **start, off_t off, int count,
while (slicecom_framings[i].value && while (slicecom_framings[i].value &&
slicecom_framings[i].value != board->framing) slicecom_framings[i].value != board->framing)
i++; i++;
len += snprintf(page + len, PAGE_SIZE - len, "%s\n", len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
slicecom_framings[i].name); slicecom_framings[i].name);
} }
else if (!strcmp(file->name, FILENAME_LINECODE)) else if (!strcmp(file->name, FILENAME_LINECODE))
...@@ -2323,7 +2323,7 @@ static int munich_read_proc(char *page, char **start, off_t off, int count, ...@@ -2323,7 +2323,7 @@ static int munich_read_proc(char *page, char **start, off_t off, int count,
while (slicecom_linecodes[i].value && while (slicecom_linecodes[i].value &&
slicecom_linecodes[i].value != board->linecode) slicecom_linecodes[i].value != board->linecode)
i++; i++;
len += snprintf(page + len, PAGE_SIZE - len, "%s\n", len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
slicecom_linecodes[i].name); slicecom_linecodes[i].name);
} }
else if (!strcmp(file->name, FILENAME_CLOCK_SOURCE)) else if (!strcmp(file->name, FILENAME_CLOCK_SOURCE))
...@@ -2333,7 +2333,7 @@ static int munich_read_proc(char *page, char **start, off_t off, int count, ...@@ -2333,7 +2333,7 @@ static int munich_read_proc(char *page, char **start, off_t off, int count,
slicecom_clock_sources[i].value != board->clock_source) slicecom_clock_sources[i].value != board->clock_source)
i++; i++;
len += len +=
snprintf(page + len, PAGE_SIZE - len, "%s\n", scnprintf(page + len, PAGE_SIZE - len, "%s\n",
slicecom_clock_sources[i].name); slicecom_clock_sources[i].name);
} }
else if (!strcmp(file->name, FILENAME_LOOPBACK)) else if (!strcmp(file->name, FILENAME_LOOPBACK))
...@@ -2342,18 +2342,18 @@ static int munich_read_proc(char *page, char **start, off_t off, int count, ...@@ -2342,18 +2342,18 @@ static int munich_read_proc(char *page, char **start, off_t off, int count,
while (slicecom_loopbacks[i].value && while (slicecom_loopbacks[i].value &&
slicecom_loopbacks[i].value != board->loopback) slicecom_loopbacks[i].value != board->loopback)
i++; i++;
len += snprintf(page + len, PAGE_SIZE - len, "%s\n", len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
slicecom_loopbacks[i].name); slicecom_loopbacks[i].name);
} }
/* We set permissions to write-only for REG and LBIREG, but root can read them anyway: */ /* We set permissions to write-only for REG and LBIREG, but root can read them anyway: */
else if (!strcmp(file->name, FILENAME_REG)) else if (!strcmp(file->name, FILENAME_REG))
{ {
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"%s: " FILENAME_REG ": write-only file\n", dev->name); "%s: " FILENAME_REG ": write-only file\n", dev->name);
} }
else if (!strcmp(file->name, FILENAME_LBIREG)) else if (!strcmp(file->name, FILENAME_LBIREG))
{ {
len += snprintf(page + len, PAGE_SIZE - len, len += scnprintf(page + len, PAGE_SIZE - len,
"%s: " FILENAME_LBIREG ": write-only file\n", dev->name); "%s: " FILENAME_LBIREG ": write-only file\n", dev->name);
} }
else else
......
...@@ -475,7 +475,7 @@ dino_card_setup(struct pci_bus *bus, unsigned long base_addr) ...@@ -475,7 +475,7 @@ dino_card_setup(struct pci_bus *bus, unsigned long base_addr)
res = &dino_dev->hba.lmmio_space; res = &dino_dev->hba.lmmio_space;
res->flags = IORESOURCE_MEM; res->flags = IORESOURCE_MEM;
size = snprintf(name, sizeof(name), "Dino LMMIO (%s)", bus->bridge->bus_id); size = scnprintf(name, sizeof(name), "Dino LMMIO (%s)", bus->bridge->bus_id);
res->name = kmalloc(size+1, GFP_KERNEL); res->name = kmalloc(size+1, GFP_KERNEL);
if(res->name) if(res->name)
strcpy((char *)res->name, name); strcpy((char *)res->name, name);
......
...@@ -29,7 +29,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -29,7 +29,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
/* stuff we want to pass to /sbin/hotplug */ /* stuff we want to pass to /sbin/hotplug */
envp[i++] = scratch; envp[i++] = scratch;
length += snprintf (scratch, buffer_size - length, "PCI_CLASS=%04X", length += scnprintf (scratch, buffer_size - length, "PCI_CLASS=%04X",
pdev->class); pdev->class);
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM; return -ENOMEM;
...@@ -37,7 +37,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -37,7 +37,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
scratch += length; scratch += length;
envp[i++] = scratch; envp[i++] = scratch;
length += snprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X", length += scnprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X",
pdev->vendor, pdev->device); pdev->vendor, pdev->device);
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM; return -ENOMEM;
...@@ -45,7 +45,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -45,7 +45,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
scratch += length; scratch += length;
envp[i++] = scratch; envp[i++] = scratch;
length += snprintf (scratch, buffer_size - length, length += scnprintf (scratch, buffer_size - length,
"PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor,
pdev->subsystem_device); pdev->subsystem_device);
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
...@@ -54,7 +54,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -54,7 +54,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
scratch += length; scratch += length;
envp[i++] = scratch; envp[i++] = scratch;
length += snprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s", length += scnprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s",
pci_name(pdev)); pci_name(pdev));
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM; return -ENOMEM;
......
...@@ -81,7 +81,7 @@ tape_medium_state_show(struct device *dev, char *buf) ...@@ -81,7 +81,7 @@ tape_medium_state_show(struct device *dev, char *buf)
struct tape_device *tdev; struct tape_device *tdev;
tdev = (struct tape_device *) dev->driver_data; tdev = (struct tape_device *) dev->driver_data;
return snprintf(buf, PAGE_SIZE, "%i\n", tdev->medium_state); return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->medium_state);
} }
static static
...@@ -93,7 +93,7 @@ tape_first_minor_show(struct device *dev, char *buf) ...@@ -93,7 +93,7 @@ tape_first_minor_show(struct device *dev, char *buf)
struct tape_device *tdev; struct tape_device *tdev;
tdev = (struct tape_device *) dev->driver_data; tdev = (struct tape_device *) dev->driver_data;
return snprintf(buf, PAGE_SIZE, "%i\n", tdev->first_minor); return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->first_minor);
} }
static static
...@@ -105,7 +105,7 @@ tape_state_show(struct device *dev, char *buf) ...@@ -105,7 +105,7 @@ tape_state_show(struct device *dev, char *buf)
struct tape_device *tdev; struct tape_device *tdev;
tdev = (struct tape_device *) dev->driver_data; tdev = (struct tape_device *) dev->driver_data;
return snprintf(buf, PAGE_SIZE, "%s\n", (tdev->first_minor < 0) ? return scnprintf(buf, PAGE_SIZE, "%s\n", (tdev->first_minor < 0) ?
"OFFLINE" : tape_state_verbose[tdev->tape_state]); "OFFLINE" : tape_state_verbose[tdev->tape_state]);
} }
...@@ -120,17 +120,17 @@ tape_operation_show(struct device *dev, char *buf) ...@@ -120,17 +120,17 @@ tape_operation_show(struct device *dev, char *buf)
tdev = (struct tape_device *) dev->driver_data; tdev = (struct tape_device *) dev->driver_data;
if (tdev->first_minor < 0) if (tdev->first_minor < 0)
return snprintf(buf, PAGE_SIZE, "N/A\n"); return scnprintf(buf, PAGE_SIZE, "N/A\n");
spin_lock_irq(get_ccwdev_lock(tdev->cdev)); spin_lock_irq(get_ccwdev_lock(tdev->cdev));
if (list_empty(&tdev->req_queue)) if (list_empty(&tdev->req_queue))
rc = snprintf(buf, PAGE_SIZE, "---\n"); rc = scnprintf(buf, PAGE_SIZE, "---\n");
else { else {
struct tape_request *req; struct tape_request *req;
req = list_entry(tdev->req_queue.next, struct tape_request, req = list_entry(tdev->req_queue.next, struct tape_request,
list); list);
rc = snprintf(buf, PAGE_SIZE, "%s\n", tape_op_verbose[req->op]); rc = scnprintf(buf,PAGE_SIZE, "%s\n", tape_op_verbose[req->op]);
} }
spin_unlock_irq(get_ccwdev_lock(tdev->cdev)); spin_unlock_irq(get_ccwdev_lock(tdev->cdev));
return rc; return rc;
...@@ -146,7 +146,7 @@ tape_blocksize_show(struct device *dev, char *buf) ...@@ -146,7 +146,7 @@ tape_blocksize_show(struct device *dev, char *buf)
tdev = (struct tape_device *) dev->driver_data; tdev = (struct tape_device *) dev->driver_data;
return snprintf(buf, PAGE_SIZE, "%i\n", tdev->char_data.block_size); return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->char_data.block_size);
} }
static static
......
...@@ -73,7 +73,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -73,7 +73,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp,
/* what we want to pass to /sbin/hotplug */ /* what we want to pass to /sbin/hotplug */
envp[i++] = buffer; envp[i++] = buffer;
length += snprintf(buffer, buffer_size - length, "CU_TYPE=%04X", length += scnprintf(buffer, buffer_size - length, "CU_TYPE=%04X",
cdev->id.cu_type); cdev->id.cu_type);
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM; return -ENOMEM;
...@@ -81,7 +81,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -81,7 +81,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp,
buffer += length; buffer += length;
envp[i++] = buffer; envp[i++] = buffer;
length += snprintf(buffer, buffer_size - length, "CU_MODEL=%02X", length += scnprintf(buffer, buffer_size - length, "CU_MODEL=%02X",
cdev->id.cu_model); cdev->id.cu_model);
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM; return -ENOMEM;
...@@ -90,7 +90,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -90,7 +90,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp,
/* The next two can be zero, that's ok for us */ /* The next two can be zero, that's ok for us */
envp[i++] = buffer; envp[i++] = buffer;
length += snprintf(buffer, buffer_size - length, "DEV_TYPE=%04X", length += scnprintf(buffer, buffer_size - length, "DEV_TYPE=%04X",
cdev->id.dev_type); cdev->id.dev_type);
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM; return -ENOMEM;
...@@ -98,7 +98,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -98,7 +98,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp,
buffer += length; buffer += length;
envp[i++] = buffer; envp[i++] = buffer;
length += snprintf(buffer, buffer_size - length, "DEV_MODEL=%02X", length += scnprintf(buffer, buffer_size - length, "DEV_MODEL=%02X",
cdev->id.dev_model); cdev->id.dev_model);
if ((buffer_size - length <= 0) || (i >= num_envp)) if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM; return -ENOMEM;
......
...@@ -557,8 +557,7 @@ static int resp_inquiry(unsigned char * cmd, int target, unsigned char * buff, ...@@ -557,8 +557,7 @@ static int resp_inquiry(unsigned char * cmd, int target, unsigned char * buff,
dev_id_num = ((devip->sdbg_host->shost->host_no + 1) * 2000) + dev_id_num = ((devip->sdbg_host->shost->host_no + 1) * 2000) +
(devip->target * 1000) + devip->lun; (devip->target * 1000) + devip->lun;
len = snprintf(dev_id_str, 6, "%d", dev_id_num); len = scnprintf(dev_id_str, 6, "%d", dev_id_num);
len = (len > 6) ? 6 : len;
if (0 == cmd[2]) { /* supported vital product data pages */ if (0 == cmd[2]) { /* supported vital product data pages */
arr[3] = 3; arr[3] = 3;
arr[4] = 0x0; /* this page */ arr[4] = 0x0; /* this page */
...@@ -1309,7 +1308,7 @@ static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **sta ...@@ -1309,7 +1308,7 @@ static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **sta
static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_delay); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_delay);
} }
static ssize_t sdebug_delay_store(struct device_driver * ddp, static ssize_t sdebug_delay_store(struct device_driver * ddp,
...@@ -1331,7 +1330,7 @@ DRIVER_ATTR(delay, S_IRUGO | S_IWUSR, sdebug_delay_show, ...@@ -1331,7 +1330,7 @@ DRIVER_ATTR(delay, S_IRUGO | S_IWUSR, sdebug_delay_show,
static ssize_t sdebug_opts_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_opts_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "0x%x\n", scsi_debug_opts); return scnprintf(buf, PAGE_SIZE, "0x%x\n", scsi_debug_opts);
} }
static ssize_t sdebug_opts_store(struct device_driver * ddp, static ssize_t sdebug_opts_store(struct device_driver * ddp,
...@@ -1360,7 +1359,7 @@ DRIVER_ATTR(opts, S_IRUGO | S_IWUSR, sdebug_opts_show, ...@@ -1360,7 +1359,7 @@ DRIVER_ATTR(opts, S_IRUGO | S_IWUSR, sdebug_opts_show,
static ssize_t sdebug_num_tgts_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_num_tgts_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_tgts); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_tgts);
} }
static ssize_t sdebug_num_tgts_store(struct device_driver * ddp, static ssize_t sdebug_num_tgts_store(struct device_driver * ddp,
const char * buf, size_t count) const char * buf, size_t count)
...@@ -1378,13 +1377,13 @@ DRIVER_ATTR(num_tgts, S_IRUGO | S_IWUSR, sdebug_num_tgts_show, ...@@ -1378,13 +1377,13 @@ DRIVER_ATTR(num_tgts, S_IRUGO | S_IWUSR, sdebug_num_tgts_show,
static ssize_t sdebug_dev_size_mb_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_dev_size_mb_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dev_size_mb); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dev_size_mb);
} }
DRIVER_ATTR(dev_size_mb, S_IRUGO, sdebug_dev_size_mb_show, NULL) DRIVER_ATTR(dev_size_mb, S_IRUGO, sdebug_dev_size_mb_show, NULL)
static ssize_t sdebug_every_nth_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_every_nth_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_every_nth); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_every_nth);
} }
static ssize_t sdebug_every_nth_store(struct device_driver * ddp, static ssize_t sdebug_every_nth_store(struct device_driver * ddp,
const char * buf, size_t count) const char * buf, size_t count)
...@@ -1403,7 +1402,7 @@ DRIVER_ATTR(every_nth, S_IRUGO | S_IWUSR, sdebug_every_nth_show, ...@@ -1403,7 +1402,7 @@ DRIVER_ATTR(every_nth, S_IRUGO | S_IWUSR, sdebug_every_nth_show,
static ssize_t sdebug_max_luns_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_max_luns_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_luns); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_luns);
} }
static ssize_t sdebug_max_luns_store(struct device_driver * ddp, static ssize_t sdebug_max_luns_store(struct device_driver * ddp,
const char * buf, size_t count) const char * buf, size_t count)
...@@ -1421,13 +1420,13 @@ DRIVER_ATTR(max_luns, S_IRUGO | S_IWUSR, sdebug_max_luns_show, ...@@ -1421,13 +1420,13 @@ DRIVER_ATTR(max_luns, S_IRUGO | S_IWUSR, sdebug_max_luns_show,
static ssize_t sdebug_scsi_level_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_scsi_level_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level);
} }
DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL) DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL)
static ssize_t sdebug_add_host_show(struct device_driver * ddp, char * buf) static ssize_t sdebug_add_host_show(struct device_driver * ddp, char * buf)
{ {
return snprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_add_host); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_add_host);
} }
static ssize_t sdebug_add_host_store(struct device_driver * ddp, static ssize_t sdebug_add_host_store(struct device_driver * ddp,
......
...@@ -1111,7 +1111,7 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size) ...@@ -1111,7 +1111,7 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
int t; int t;
/* int_status is the same format ... */ /* int_status is the same format ... */
t = snprintf(*next, *size, t = scnprintf(*next, *size,
"%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
label, mask, label, mask,
(mask & INT_PWRDETECT) ? " power" : "", (mask & INT_PWRDETECT) ? " power" : "",
...@@ -1164,7 +1164,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1164,7 +1164,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
/* basic device status */ /* basic device status */
tmp = readl(&regs->power_detect); tmp = readl(&regs->power_detect);
is_usb_connected = tmp & PW_DETECT; is_usb_connected = tmp & PW_DETECT;
t = snprintf(next, size, t = scnprintf(next, size,
"%s - %s\n" "%s - %s\n"
"%s version: %s %s\n" "%s version: %s %s\n"
"Gadget driver: %s\n" "Gadget driver: %s\n"
...@@ -1198,7 +1198,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1198,7 +1198,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
goto done; goto done;
/* registers for (active) device and ep0 */ /* registers for (active) device and ep0 */
t = snprintf(next, size, "\nirqs %lu\ndataset %02x " t = scnprintf(next, size, "\nirqs %lu\ndataset %02x "
"single.bcs %02x.%02x state %x addr %u\n", "single.bcs %02x.%02x state %x addr %u\n",
dev->irqs, readl(&regs->DataSet), dev->irqs, readl(&regs->DataSet),
readl(&regs->EPxSingle), readl(&regs->EPxBCS), readl(&regs->EPxSingle), readl(&regs->EPxBCS),
...@@ -1208,7 +1208,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1208,7 +1208,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
next += t; next += t;
tmp = readl(&regs->dma_master); tmp = readl(&regs->dma_master);
t = snprintf(next, size, t = scnprintf(next, size,
"dma %03X =" EIGHTBITS "%s %s\n", tmp, "dma %03X =" EIGHTBITS "%s %s\n", tmp,
(tmp & MST_EOPB_DIS) ? " eopb-" : "", (tmp & MST_EOPB_DIS) ? " eopb-" : "",
(tmp & MST_EOPB_ENA) ? " eopb+" : "", (tmp & MST_EOPB_ENA) ? " eopb+" : "",
...@@ -1237,7 +1237,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1237,7 +1237,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
continue; continue;
tmp = readl(ep->reg_status); tmp = readl(ep->reg_status);
t = snprintf(next, size, t = scnprintf(next, size,
"%s %s max %u %s, irqs %lu, " "%s %s max %u %s, irqs %lu, "
"status %02x (%s) " FOURBITS "\n", "status %02x (%s) " FOURBITS "\n",
ep->ep.name, ep->ep.name,
...@@ -1277,7 +1277,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1277,7 +1277,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
next += t; next += t;
if (list_empty(&ep->queue)) { if (list_empty(&ep->queue)) {
t = snprintf(next, size, "\t(nothing queued)\n"); t = scnprintf(next, size, "\t(nothing queued)\n");
if (t <= 0 || t > size) if (t <= 0 || t > size)
goto done; goto done;
size -= t; size -= t;
...@@ -1295,7 +1295,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1295,7 +1295,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
} else } else
tmp = req->req.actual; tmp = req->req.actual;
t = snprintf(next, size, t = scnprintf(next, size,
"\treq %p len %u/%u buf %p\n", "\treq %p len %u/%u buf %p\n",
&req->req, tmp, req->req.length, &req->req, tmp, req->req.length,
req->req.buf); req->req.buf);
...@@ -1913,7 +1913,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1913,7 +1913,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
INFO(dev, "%s\n", driver_desc); INFO(dev, "%s\n", driver_desc);
INFO(dev, "version: " DRIVER_VERSION " %s\n", dmastr()); INFO(dev, "version: " DRIVER_VERSION " %s\n", dmastr());
#ifndef __sparc__ #ifndef __sparc__
snprintf(buf, sizeof buf, "%d", pdev->irq); scnprintf(buf, sizeof buf, "%d", pdev->irq);
bufp = buf; bufp = buf;
#else #else
bufp = __irq_itoa(pdev->irq); bufp = __irq_itoa(pdev->irq);
......
...@@ -1439,7 +1439,7 @@ show_function (struct device *_dev, char *buf) ...@@ -1439,7 +1439,7 @@ show_function (struct device *_dev, char *buf)
|| !dev->driver->function || !dev->driver->function
|| strlen (dev->driver->function) > PAGE_SIZE) || strlen (dev->driver->function) > PAGE_SIZE)
return 0; return 0;
return snprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function); return scnprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function);
} }
static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
...@@ -1465,7 +1465,7 @@ show_registers (struct device *_dev, char *buf) ...@@ -1465,7 +1465,7 @@ show_registers (struct device *_dev, char *buf)
s = "(none)"; s = "(none)";
/* Main Control Registers */ /* Main Control Registers */
t = snprintf (next, size, "%s version " DRIVER_VERSION t = scnprintf (next, size, "%s version " DRIVER_VERSION
", chiprev %04x, dma %s\n\n" ", chiprev %04x, dma %s\n\n"
"devinit %03x fifoctl %08x gadget '%s'\n" "devinit %03x fifoctl %08x gadget '%s'\n"
"pci irqenb0 %02x irqenb1 %08x " "pci irqenb0 %02x irqenb1 %08x "
...@@ -1497,7 +1497,7 @@ show_registers (struct device *_dev, char *buf) ...@@ -1497,7 +1497,7 @@ show_registers (struct device *_dev, char *buf)
/* full speed bit (6) not working?? */ /* full speed bit (6) not working?? */
} else } else
s = "not attached"; s = "not attached";
t = snprintf (next, size, t = scnprintf (next, size,
"stdrsp %08x usbctl %08x usbstat %08x " "stdrsp %08x usbctl %08x usbstat %08x "
"addr 0x%02x (%s)\n", "addr 0x%02x (%s)\n",
readl (&dev->usb->stdrsp), t1, t2, readl (&dev->usb->stdrsp), t1, t2,
...@@ -1519,7 +1519,7 @@ show_registers (struct device *_dev, char *buf) ...@@ -1519,7 +1519,7 @@ show_registers (struct device *_dev, char *buf)
t1 = readl (&ep->regs->ep_cfg); t1 = readl (&ep->regs->ep_cfg);
t2 = readl (&ep->regs->ep_rsp) & 0xff; t2 = readl (&ep->regs->ep_rsp) & 0xff;
t = snprintf (next, size, t = scnprintf (next, size,
"\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s" "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
"irqenb %02x\n", "irqenb %02x\n",
ep->ep.name, t1, t2, ep->ep.name, t1, t2,
...@@ -1543,7 +1543,7 @@ show_registers (struct device *_dev, char *buf) ...@@ -1543,7 +1543,7 @@ show_registers (struct device *_dev, char *buf)
size -= t; size -= t;
next += t; next += t;
t = snprintf (next, size, t = scnprintf (next, size,
"\tstat %08x avail %04x " "\tstat %08x avail %04x "
"(ep%d%s-%s)%s\n", "(ep%d%s-%s)%s\n",
readl (&ep->regs->ep_stat), readl (&ep->regs->ep_stat),
...@@ -1557,7 +1557,7 @@ show_registers (struct device *_dev, char *buf) ...@@ -1557,7 +1557,7 @@ show_registers (struct device *_dev, char *buf)
if (!ep->dma) if (!ep->dma)
continue; continue;
t = snprintf (next, size, t = scnprintf (next, size,
" dma\tctl %08x stat %08x count %08x\n" " dma\tctl %08x stat %08x count %08x\n"
"\taddr %08x desc %08x\n", "\taddr %08x desc %08x\n",
readl (&ep->dma->dmactl), readl (&ep->dma->dmactl),
...@@ -1574,7 +1574,7 @@ show_registers (struct device *_dev, char *buf) ...@@ -1574,7 +1574,7 @@ show_registers (struct device *_dev, char *buf)
// none yet // none yet
/* Statistics */ /* Statistics */
t = snprintf (next, size, "\nirqs: "); t = scnprintf (next, size, "\nirqs: ");
size -= t; size -= t;
next += t; next += t;
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
...@@ -1583,12 +1583,12 @@ show_registers (struct device *_dev, char *buf) ...@@ -1583,12 +1583,12 @@ show_registers (struct device *_dev, char *buf)
ep = &dev->ep [i]; ep = &dev->ep [i];
if (i && !ep->irqs) if (i && !ep->irqs)
continue; continue;
t = snprintf (next, size, " %s/%lu", ep->ep.name, ep->irqs); t = scnprintf (next, size, " %s/%lu", ep->ep.name, ep->irqs);
size -= t; size -= t;
next += t; next += t;
} }
t = snprintf (next, size, "\n"); t = scnprintf (next, size, "\n");
size -= t; size -= t;
next += t; next += t;
...@@ -1624,7 +1624,7 @@ show_queues (struct device *_dev, char *buf) ...@@ -1624,7 +1624,7 @@ show_queues (struct device *_dev, char *buf)
if (!d) if (!d)
continue; continue;
t = d->bEndpointAddress; t = d->bEndpointAddress;
t = snprintf (next, size, t = scnprintf (next, size,
"\n%s (ep%d%s-%s) max %04x %s fifo %d\n", "\n%s (ep%d%s-%s) max %04x %s fifo %d\n",
ep->ep.name, t & USB_ENDPOINT_NUMBER_MASK, ep->ep.name, t & USB_ENDPOINT_NUMBER_MASK,
(t & USB_DIR_IN) ? "in" : "out", (t & USB_DIR_IN) ? "in" : "out",
...@@ -1641,7 +1641,7 @@ show_queues (struct device *_dev, char *buf) ...@@ -1641,7 +1641,7 @@ show_queues (struct device *_dev, char *buf)
ep->dma ? "dma" : "pio", ep->fifo_size ep->dma ? "dma" : "pio", ep->fifo_size
); );
} else /* ep0 should only have one transfer queued */ } else /* ep0 should only have one transfer queued */
t = snprintf (next, size, "ep0 max 64 pio %s\n", t = scnprintf (next, size, "ep0 max 64 pio %s\n",
ep->is_in ? "in" : "out"); ep->is_in ? "in" : "out");
if (t <= 0 || t > size) if (t <= 0 || t > size)
goto done; goto done;
...@@ -1649,7 +1649,7 @@ show_queues (struct device *_dev, char *buf) ...@@ -1649,7 +1649,7 @@ show_queues (struct device *_dev, char *buf)
next += t; next += t;
if (list_empty (&ep->queue)) { if (list_empty (&ep->queue)) {
t = snprintf (next, size, "\t(nothing queued)\n"); t = scnprintf (next, size, "\t(nothing queued)\n");
if (t <= 0 || t > size) if (t <= 0 || t > size)
goto done; goto done;
size -= t; size -= t;
...@@ -1658,14 +1658,14 @@ show_queues (struct device *_dev, char *buf) ...@@ -1658,14 +1658,14 @@ show_queues (struct device *_dev, char *buf)
} }
list_for_each_entry (req, &ep->queue, queue) { list_for_each_entry (req, &ep->queue, queue) {
if (ep->dma && req->td_dma == readl (&ep->dma->dmadesc)) if (ep->dma && req->td_dma == readl (&ep->dma->dmadesc))
t = snprintf (next, size, t = scnprintf (next, size,
"\treq %p len %d/%d " "\treq %p len %d/%d "
"buf %p (dmacount %08x)\n", "buf %p (dmacount %08x)\n",
&req->req, req->req.actual, &req->req, req->req.actual,
req->req.length, req->req.buf, req->req.length, req->req.buf,
readl (&ep->dma->dmacount)); readl (&ep->dma->dmacount));
else else
t = snprintf (next, size, t = scnprintf (next, size,
"\treq %p len %d/%d buf %p\n", "\treq %p len %d/%d buf %p\n",
&req->req, req->req.actual, &req->req, req->req.actual,
req->req.length, req->req.buf); req->req.length, req->req.buf);
...@@ -1678,7 +1678,7 @@ show_queues (struct device *_dev, char *buf) ...@@ -1678,7 +1678,7 @@ show_queues (struct device *_dev, char *buf)
struct net2280_dma *td; struct net2280_dma *td;
td = req->td; td = req->td;
t = snprintf (next, size, "\t td %08x " t = scnprintf (next, size, "\t td %08x "
" count %08x buf %08x desc %08x\n", " count %08x buf %08x desc %08x\n",
req->td_dma, td->dmacount, req->td_dma, td->dmacount,
td->dmaaddr, td->dmadesc); td->dmaaddr, td->dmadesc);
...@@ -2788,7 +2788,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2788,7 +2788,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
goto done; goto done;
} }
#ifndef __sparc__ #ifndef __sparc__
snprintf (buf, sizeof buf, "%d", pdev->irq); scnprintf (buf, sizeof buf, "%d", pdev->irq);
bufp = buf; bufp = buf;
#else #else
bufp = __irq_itoa(pdev->irq); bufp = __irq_itoa(pdev->irq);
......
...@@ -1232,7 +1232,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1232,7 +1232,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
local_irq_save(flags); local_irq_save(flags);
/* basic device status */ /* basic device status */
t = snprintf(next, size, DRIVER_DESC "\n" t = scnprintf(next, size, DRIVER_DESC "\n"
"%s version: %s\nGadget driver: %s\nHost %s\n\n", "%s version: %s\nGadget driver: %s\nHost %s\n\n",
driver_name, DRIVER_VERSION SIZE_STR DMASTR, driver_name, DRIVER_VERSION SIZE_STR DMASTR,
dev->driver ? dev->driver->driver.name : "(none)", dev->driver ? dev->driver->driver.name : "(none)",
...@@ -1241,14 +1241,14 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1241,14 +1241,14 @@ udc_proc_read(char *page, char **start, off_t off, int count,
next += t; next += t;
/* registers for device and ep0 */ /* registers for device and ep0 */
t = snprintf(next, size, t = scnprintf(next, size,
"uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", "uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n",
UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL);
size -= t; size -= t;
next += t; next += t;
tmp = UDCCR; tmp = UDCCR;
t = snprintf(next, size, t = scnprintf(next, size,
"udccr %02X =%s%s%s%s%s%s%s%s\n", tmp, "udccr %02X =%s%s%s%s%s%s%s%s\n", tmp,
(tmp & UDCCR_REM) ? " rem" : "", (tmp & UDCCR_REM) ? " rem" : "",
(tmp & UDCCR_RSTIR) ? " rstir" : "", (tmp & UDCCR_RSTIR) ? " rstir" : "",
...@@ -1262,7 +1262,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1262,7 +1262,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
next += t; next += t;
tmp = UDCCS0; tmp = UDCCS0;
t = snprintf(next, size, t = scnprintf(next, size,
"udccs0 %02X =%s%s%s%s%s%s%s%s\n", tmp, "udccs0 %02X =%s%s%s%s%s%s%s%s\n", tmp,
(tmp & UDCCS0_SA) ? " sa" : "", (tmp & UDCCS0_SA) ? " sa" : "",
(tmp & UDCCS0_RNE) ? " rne" : "", (tmp & UDCCS0_RNE) ? " rne" : "",
...@@ -1277,7 +1277,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1277,7 +1277,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
if (dev->has_cfr) { if (dev->has_cfr) {
tmp = UDCCFR; tmp = UDCCFR;
t = snprintf(next, size, t = scnprintf(next, size,
"udccfr %02X =%s%s\n", tmp, "udccfr %02X =%s%s\n", tmp,
(tmp & UDCCFR_AREN) ? " aren" : "", (tmp & UDCCFR_AREN) ? " aren" : "",
(tmp & UDCCFR_ACM) ? " acm" : ""); (tmp & UDCCFR_ACM) ? " acm" : "");
...@@ -1288,7 +1288,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1288,7 +1288,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
if (!is_usb_connected() || !dev->driver) if (!is_usb_connected() || !dev->driver)
goto done; goto done;
t = snprintf(next, size, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n", t = scnprintf(next, size, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n",
dev->stats.write.bytes, dev->stats.write.ops, dev->stats.write.bytes, dev->stats.write.ops,
dev->stats.read.bytes, dev->stats.read.ops, dev->stats.read.bytes, dev->stats.read.ops,
dev->stats.irqs); dev->stats.irqs);
...@@ -1308,7 +1308,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1308,7 +1308,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
if (!d) if (!d)
continue; continue;
tmp = *dev->ep [i].reg_udccs; tmp = *dev->ep [i].reg_udccs;
t = snprintf(next, size, t = scnprintf(next, size,
"%s max %d %s udccs %02x irqs %lu/%lu\n", "%s max %d %s udccs %02x irqs %lu/%lu\n",
ep->ep.name, le16_to_cpu (d->wMaxPacketSize), ep->ep.name, le16_to_cpu (d->wMaxPacketSize),
(ep->dma >= 0) ? "dma" : "pio", tmp, (ep->dma >= 0) ? "dma" : "pio", tmp,
...@@ -1316,7 +1316,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1316,7 +1316,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
/* TODO translate all five groups of udccs bits! */ /* TODO translate all five groups of udccs bits! */
} else /* ep0 should only have one transfer queued */ } else /* ep0 should only have one transfer queued */
t = snprintf(next, size, "ep0 max 16 pio irqs %lu\n", t = scnprintf(next, size, "ep0 max 16 pio irqs %lu\n",
ep->pio_irqs); ep->pio_irqs);
if (t <= 0 || t > size) if (t <= 0 || t > size)
goto done; goto done;
...@@ -1324,7 +1324,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1324,7 +1324,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
next += t; next += t;
if (list_empty(&ep->queue)) { if (list_empty(&ep->queue)) {
t = snprintf(next, size, "\t(nothing queued)\n"); t = scnprintf(next, size, "\t(nothing queued)\n");
if (t <= 0 || t > size) if (t <= 0 || t > size)
goto done; goto done;
size -= t; size -= t;
...@@ -1334,7 +1334,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1334,7 +1334,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
list_for_each_entry(req, &ep->queue, queue) { list_for_each_entry(req, &ep->queue, queue) {
#ifdef USE_DMA #ifdef USE_DMA
if (ep->dma >= 0 && req->queue.prev == &ep->queue) if (ep->dma >= 0 && req->queue.prev == &ep->queue)
t = snprintf(next, size, t = scnprintf(next, size,
"\treq %p len %d/%d " "\treq %p len %d/%d "
"buf %p (dma%d dcmd %08x)\n", "buf %p (dma%d dcmd %08x)\n",
&req->req, req->req.actual, &req->req, req->req.actual,
...@@ -1344,7 +1344,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1344,7 +1344,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
); );
else else
#endif #endif
t = snprintf(next, size, t = scnprintf(next, size,
"\treq %p len %d/%d buf %p\n", "\treq %p len %d/%d buf %p\n",
&req->req, req->req.actual, &req->req, req->req.actual,
req->req.length, req->req.buf); req->req.length, req->req.buf);
...@@ -1382,7 +1382,7 @@ show_function (struct device *_dev, char *buf) ...@@ -1382,7 +1382,7 @@ show_function (struct device *_dev, char *buf)
|| !dev->driver->function || !dev->driver->function
|| strlen (dev->driver->function) > PAGE_SIZE) || strlen (dev->driver->function) > PAGE_SIZE)
return 0; return 0;
return snprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function); return scnprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function);
} }
static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
......
...@@ -173,7 +173,7 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) ...@@ -173,7 +173,7 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
static int __attribute__((__unused__)) static int __attribute__((__unused__))
dbg_status_buf (char *buf, unsigned len, char *label, u32 status) dbg_status_buf (char *buf, unsigned len, char *label, u32 status)
{ {
return snprintf (buf, len, return scnprintf (buf, len,
"%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s", "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
label, label [0] ? " " : "", status, label, label [0] ? " " : "", status,
(status & STS_ASS) ? " Async" : "", (status & STS_ASS) ? " Async" : "",
...@@ -192,7 +192,7 @@ dbg_status_buf (char *buf, unsigned len, char *label, u32 status) ...@@ -192,7 +192,7 @@ dbg_status_buf (char *buf, unsigned len, char *label, u32 status)
static int __attribute__((__unused__)) static int __attribute__((__unused__))
dbg_intr_buf (char *buf, unsigned len, char *label, u32 enable) dbg_intr_buf (char *buf, unsigned len, char *label, u32 enable)
{ {
return snprintf (buf, len, return scnprintf (buf, len,
"%s%sintrenable %02x%s%s%s%s%s%s", "%s%sintrenable %02x%s%s%s%s%s%s",
label, label [0] ? " " : "", enable, label, label [0] ? " " : "", enable,
(enable & STS_IAA) ? " IAA" : "", (enable & STS_IAA) ? " IAA" : "",
...@@ -209,7 +209,7 @@ static const char *const fls_strings [] = ...@@ -209,7 +209,7 @@ static const char *const fls_strings [] =
static int dbg_command_buf (char *buf, unsigned len, char *label, u32 command) static int dbg_command_buf (char *buf, unsigned len, char *label, u32 command)
{ {
return snprintf (buf, len, return scnprintf (buf, len,
"%s%scommand %06x %s=%d ithresh=%d%s%s%s%s period=%s%s %s", "%s%scommand %06x %s=%d ithresh=%d%s%s%s%s period=%s%s %s",
label, label [0] ? " " : "", command, label, label [0] ? " " : "", command,
(command & CMD_PARK) ? "park" : "(park)", (command & CMD_PARK) ? "park" : "(park)",
...@@ -238,7 +238,7 @@ dbg_port_buf (char *buf, unsigned len, char *label, int port, u32 status) ...@@ -238,7 +238,7 @@ dbg_port_buf (char *buf, unsigned len, char *label, int port, u32 status)
default: sig = "?"; break; default: sig = "?"; break;
} }
return snprintf (buf, len, return scnprintf (buf, len,
"%s%sport %d status %06x%s%s sig=%s %s%s%s%s%s%s%s%s%s", "%s%sport %d status %06x%s%s sig=%s %s%s%s%s%s%s%s%s%s",
label, label [0] ? " " : "", port, status, label, label [0] ? " " : "", port, status,
(status & PORT_POWER) ? " POWER" : "", (status & PORT_POWER) ? " POWER" : "",
...@@ -359,7 +359,7 @@ static void qh_lines ( ...@@ -359,7 +359,7 @@ static void qh_lines (
} }
scratch = cpu_to_le32p (&qh->hw_info1); scratch = cpu_to_le32p (&qh->hw_info1);
hw_curr = (mark == '*') ? cpu_to_le32p (&qh->hw_current) : 0; hw_curr = (mark == '*') ? cpu_to_le32p (&qh->hw_current) : 0;
temp = snprintf (next, size, temp = scnprintf (next, size,
"qh/%p dev%d %cs ep%d %08x %08x (%08x%c %s nak%d)", "qh/%p dev%d %cs ep%d %08x %08x (%08x%c %s nak%d)",
qh, scratch & 0x007f, qh, scratch & 0x007f,
speed_char (scratch), speed_char (scratch),
...@@ -449,7 +449,7 @@ show_async (struct class_device *class_dev, char *buf) ...@@ -449,7 +449,7 @@ show_async (struct class_device *class_dev, char *buf)
for (qh = ehci->async->qh_next.qh; size > 0 && qh; qh = qh->qh_next.qh) for (qh = ehci->async->qh_next.qh; size > 0 && qh; qh = qh->qh_next.qh)
qh_lines (ehci, qh, &next, &size); qh_lines (ehci, qh, &next, &size);
if (ehci->reclaim && size > 0) { if (ehci->reclaim && size > 0) {
temp = snprintf (next, size, "\nreclaim =\n"); temp = scnprintf (next, size, "\nreclaim =\n");
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -486,7 +486,7 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -486,7 +486,7 @@ show_periodic (struct class_device *class_dev, char *buf)
next = buf; next = buf;
size = PAGE_SIZE; size = PAGE_SIZE;
temp = snprintf (next, size, "size = %d\n", ehci->periodic_size); temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size);
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -500,14 +500,14 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -500,14 +500,14 @@ show_periodic (struct class_device *class_dev, char *buf)
continue; continue;
tag = Q_NEXT_TYPE (ehci->periodic [i]); tag = Q_NEXT_TYPE (ehci->periodic [i]);
temp = snprintf (next, size, "%4d: ", i); temp = scnprintf (next, size, "%4d: ", i);
size -= temp; size -= temp;
next += temp; next += temp;
do { do {
switch (tag) { switch (tag) {
case Q_TYPE_QH: case Q_TYPE_QH:
temp = snprintf (next, size, " qh%d-%04x/%p", temp = scnprintf (next, size, " qh%d-%04x/%p",
p.qh->period, p.qh->period,
le32_to_cpup (&p.qh->hw_info2) le32_to_cpup (&p.qh->hw_info2)
/* uframe masks */ /* uframe masks */
...@@ -520,7 +520,7 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -520,7 +520,7 @@ show_periodic (struct class_device *class_dev, char *buf)
if (seen [temp].ptr != p.ptr) if (seen [temp].ptr != p.ptr)
continue; continue;
if (p.qh->qh_next.ptr) if (p.qh->qh_next.ptr)
temp = snprintf (next, size, temp = scnprintf (next, size,
" ..."); " ...");
p.ptr = 0; p.ptr = 0;
break; break;
...@@ -545,7 +545,7 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -545,7 +545,7 @@ show_periodic (struct class_device *class_dev, char *buf)
} }
} }
temp = snprintf (next, size, temp = scnprintf (next, size,
" (%c%d ep%d%s " " (%c%d ep%d%s "
"[%d/%d] q%d p%d)", "[%d/%d] q%d p%d)",
speed_char (scratch), speed_char (scratch),
...@@ -565,20 +565,20 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -565,20 +565,20 @@ show_periodic (struct class_device *class_dev, char *buf)
} }
break; break;
case Q_TYPE_FSTN: case Q_TYPE_FSTN:
temp = snprintf (next, size, temp = scnprintf (next, size,
" fstn-%8x/%p", p.fstn->hw_prev, " fstn-%8x/%p", p.fstn->hw_prev,
p.fstn); p.fstn);
tag = Q_NEXT_TYPE (p.fstn->hw_next); tag = Q_NEXT_TYPE (p.fstn->hw_next);
p = p.fstn->fstn_next; p = p.fstn->fstn_next;
break; break;
case Q_TYPE_ITD: case Q_TYPE_ITD:
temp = snprintf (next, size, temp = scnprintf (next, size,
" itd/%p", p.itd); " itd/%p", p.itd);
tag = Q_NEXT_TYPE (p.itd->hw_next); tag = Q_NEXT_TYPE (p.itd->hw_next);
p = p.itd->itd_next; p = p.itd->itd_next;
break; break;
case Q_TYPE_SITD: case Q_TYPE_SITD:
temp = snprintf (next, size, temp = scnprintf (next, size,
" sitd/%p", p.sitd); " sitd/%p", p.sitd);
tag = Q_NEXT_TYPE (p.sitd->hw_next); tag = Q_NEXT_TYPE (p.sitd->hw_next);
p = p.sitd->sitd_next; p = p.sitd->sitd_next;
...@@ -588,7 +588,7 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -588,7 +588,7 @@ show_periodic (struct class_device *class_dev, char *buf)
next += temp; next += temp;
} while (p.ptr); } while (p.ptr);
temp = snprintf (next, size, "\n"); temp = scnprintf (next, size, "\n");
size -= temp; size -= temp;
next += temp; next += temp;
} }
...@@ -623,7 +623,7 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -623,7 +623,7 @@ show_registers (struct class_device *class_dev, char *buf)
/* Capability Registers */ /* Capability Registers */
i = HC_VERSION(readl (&ehci->caps->hc_capbase)); i = HC_VERSION(readl (&ehci->caps->hc_capbase));
temp = snprintf (next, size, temp = scnprintf (next, size,
"PCI device %s\nEHCI %x.%02x, hcd state %d (driver " DRIVER_VERSION ")\n", "PCI device %s\nEHCI %x.%02x, hcd state %d (driver " DRIVER_VERSION ")\n",
pci_name(hcd->pdev), pci_name(hcd->pdev),
i >> 8, i & 0x0ff, ehci->hcd.state); i >> 8, i & 0x0ff, ehci->hcd.state);
...@@ -632,35 +632,35 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -632,35 +632,35 @@ show_registers (struct class_device *class_dev, char *buf)
// FIXME interpret both types of params // FIXME interpret both types of params
i = readl (&ehci->caps->hcs_params); i = readl (&ehci->caps->hcs_params);
temp = snprintf (next, size, "structural params 0x%08x\n", i); temp = scnprintf (next, size, "structural params 0x%08x\n", i);
size -= temp; size -= temp;
next += temp; next += temp;
i = readl (&ehci->caps->hcc_params); i = readl (&ehci->caps->hcc_params);
temp = snprintf (next, size, "capability params 0x%08x\n", i); temp = scnprintf (next, size, "capability params 0x%08x\n", i);
size -= temp; size -= temp;
next += temp; next += temp;
/* Operational Registers */ /* Operational Registers */
temp = dbg_status_buf (scratch, sizeof scratch, label, temp = dbg_status_buf (scratch, sizeof scratch, label,
readl (&ehci->regs->status)); readl (&ehci->regs->status));
temp = snprintf (next, size, fmt, temp, scratch); temp = scnprintf (next, size, fmt, temp, scratch);
size -= temp; size -= temp;
next += temp; next += temp;
temp = dbg_command_buf (scratch, sizeof scratch, label, temp = dbg_command_buf (scratch, sizeof scratch, label,
readl (&ehci->regs->command)); readl (&ehci->regs->command));
temp = snprintf (next, size, fmt, temp, scratch); temp = scnprintf (next, size, fmt, temp, scratch);
size -= temp; size -= temp;
next += temp; next += temp;
temp = dbg_intr_buf (scratch, sizeof scratch, label, temp = dbg_intr_buf (scratch, sizeof scratch, label,
readl (&ehci->regs->intr_enable)); readl (&ehci->regs->intr_enable));
temp = snprintf (next, size, fmt, temp, scratch); temp = scnprintf (next, size, fmt, temp, scratch);
size -= temp; size -= temp;
next += temp; next += temp;
temp = snprintf (next, size, "uframe %04x\n", temp = scnprintf (next, size, "uframe %04x\n",
readl (&ehci->regs->frame_index)); readl (&ehci->regs->frame_index));
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -668,13 +668,13 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -668,13 +668,13 @@ show_registers (struct class_device *class_dev, char *buf)
for (i = 0; i < HCS_N_PORTS (ehci->hcs_params); i++) { for (i = 0; i < HCS_N_PORTS (ehci->hcs_params); i++) {
temp = dbg_port_buf (scratch, sizeof scratch, label, i, temp = dbg_port_buf (scratch, sizeof scratch, label, i,
readl (&ehci->regs->port_status [i])); readl (&ehci->regs->port_status [i]));
temp = snprintf (next, size, fmt, temp, scratch); temp = scnprintf (next, size, fmt, temp, scratch);
size -= temp; size -= temp;
next += temp; next += temp;
} }
if (ehci->reclaim) { if (ehci->reclaim) {
temp = snprintf (next, size, "reclaim qh %p%s\n", temp = scnprintf (next, size, "reclaim qh %p%s\n",
ehci->reclaim, ehci->reclaim,
ehci->reclaim_ready ? " ready" : ""); ehci->reclaim_ready ? " ready" : "");
size -= temp; size -= temp;
...@@ -682,14 +682,14 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -682,14 +682,14 @@ show_registers (struct class_device *class_dev, char *buf)
} }
#ifdef EHCI_STATS #ifdef EHCI_STATS
temp = snprintf (next, size, temp = scnprintf (next, size,
"irq normal %ld err %ld reclaim %ld (lost %ld)\n", "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim, ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
ehci->stats.lost_iaa); ehci->stats.lost_iaa);
size -= temp; size -= temp;
next += temp; next += temp;
temp = snprintf (next, size, "complete %ld unlink %ld\n", temp = scnprintf (next, size, "complete %ld unlink %ld\n",
ehci->stats.complete, ehci->stats.unlink); ehci->stats.complete, ehci->stats.unlink);
size -= temp; size -= temp;
next += temp; next += temp;
......
...@@ -76,7 +76,7 @@ urb_print (struct urb * urb, char * str, int small) ...@@ -76,7 +76,7 @@ urb_print (struct urb * urb, char * str, int small)
do { \ do { \
if (next) { \ if (next) { \
unsigned s_len; \ unsigned s_len; \
s_len = snprintf (*next, *size, format, ## arg ); \ s_len = scnprintf (*next, *size, format, ## arg ); \
*size -= s_len; *next += s_len; \ *size -= s_len; *next += s_len; \
} else \ } else \
ohci_dbg(ohci,format, ## arg ); \ ohci_dbg(ohci,format, ## arg ); \
...@@ -420,7 +420,7 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed) ...@@ -420,7 +420,7 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
struct list_head *entry; struct list_head *entry;
struct td *td; struct td *td;
temp = snprintf (buf, size, temp = scnprintf (buf, size,
"ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s", "ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
ed, ed,
(info & ED_LOWSPEED) ? 'l' : 'f', (info & ED_LOWSPEED) ? 'l' : 'f',
...@@ -442,7 +442,7 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed) ...@@ -442,7 +442,7 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
scratch = cpu_to_le32p (&td->hwINFO); scratch = cpu_to_le32p (&td->hwINFO);
cbp = le32_to_cpup (&td->hwCBP); cbp = le32_to_cpup (&td->hwCBP);
be = le32_to_cpup (&td->hwBE); be = le32_to_cpup (&td->hwBE);
temp = snprintf (buf, size, temp = scnprintf (buf, size,
"\n\ttd %p %s %d cc=%x urb %p (%08x)", "\n\ttd %p %s %d cc=%x urb %p (%08x)",
td, td,
({ char *pid; ({ char *pid;
...@@ -458,7 +458,7 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed) ...@@ -458,7 +458,7 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
buf += temp; buf += temp;
} }
temp = snprintf (buf, size, "\n"); temp = scnprintf (buf, size, "\n");
size -= temp; size -= temp;
buf += temp; buf += temp;
...@@ -515,7 +515,7 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -515,7 +515,7 @@ show_periodic (struct class_device *class_dev, char *buf)
next = buf; next = buf;
size = PAGE_SIZE; size = PAGE_SIZE;
temp = snprintf (next, size, "size = %d\n", NUM_INTS); temp = scnprintf (next, size, "size = %d\n", NUM_INTS);
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -525,12 +525,12 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -525,12 +525,12 @@ show_periodic (struct class_device *class_dev, char *buf)
if (!(ed = ohci->periodic [i])) if (!(ed = ohci->periodic [i]))
continue; continue;
temp = snprintf (next, size, "%2d [%3d]:", i, ohci->load [i]); temp = scnprintf (next, size, "%2d [%3d]:", i, ohci->load [i]);
size -= temp; size -= temp;
next += temp; next += temp;
do { do {
temp = snprintf (next, size, " ed%d/%p", temp = scnprintf (next, size, " ed%d/%p",
ed->interval, ed); ed->interval, ed);
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -550,7 +550,7 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -550,7 +550,7 @@ show_periodic (struct class_device *class_dev, char *buf)
list_for_each (entry, &ed->td_list) list_for_each (entry, &ed->td_list)
qlen++; qlen++;
temp = snprintf (next, size, temp = scnprintf (next, size,
" (%cs dev%d ep%d%s-%s qlen %u" " (%cs dev%d ep%d%s-%s qlen %u"
" max %d %08x%s%s)", " max %d %08x%s%s)",
(info & ED_LOWSPEED) ? 'l' : 'f', (info & ED_LOWSPEED) ? 'l' : 'f',
...@@ -579,7 +579,7 @@ show_periodic (struct class_device *class_dev, char *buf) ...@@ -579,7 +579,7 @@ show_periodic (struct class_device *class_dev, char *buf)
} while (ed); } while (ed);
temp = snprintf (next, size, "\n"); temp = scnprintf (next, size, "\n");
size -= temp; size -= temp;
next += temp; next += temp;
} }
...@@ -628,7 +628,7 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -628,7 +628,7 @@ show_registers (struct class_device *class_dev, char *buf)
/* other registers mostly affect frame timings */ /* other registers mostly affect frame timings */
rdata = readl (&regs->fminterval); rdata = readl (&regs->fminterval);
temp = snprintf (next, size, temp = scnprintf (next, size,
"fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n", "fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
rdata, (rdata >> 31) ? " FIT" : "", rdata, (rdata >> 31) ? " FIT" : "",
(rdata >> 16) & 0xefff, rdata & 0xffff); (rdata >> 16) & 0xefff, rdata & 0xffff);
...@@ -636,20 +636,20 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -636,20 +636,20 @@ show_registers (struct class_device *class_dev, char *buf)
next += temp; next += temp;
rdata = readl (&regs->fmremaining); rdata = readl (&regs->fmremaining);
temp = snprintf (next, size, "fmremaining 0x%08x %sFR=0x%04x\n", temp = scnprintf (next, size, "fmremaining 0x%08x %sFR=0x%04x\n",
rdata, (rdata >> 31) ? " FRT" : "", rdata, (rdata >> 31) ? " FRT" : "",
rdata & 0x3fff); rdata & 0x3fff);
size -= temp; size -= temp;
next += temp; next += temp;
rdata = readl (&regs->periodicstart); rdata = readl (&regs->periodicstart);
temp = snprintf (next, size, "periodicstart 0x%04x\n", temp = scnprintf (next, size, "periodicstart 0x%04x\n",
rdata & 0x3fff); rdata & 0x3fff);
size -= temp; size -= temp;
next += temp; next += temp;
rdata = readl (&regs->lsthresh); rdata = readl (&regs->lsthresh);
temp = snprintf (next, size, "lsthresh 0x%04x\n", temp = scnprintf (next, size, "lsthresh 0x%04x\n",
rdata & 0x3fff); rdata & 0x3fff);
size -= temp; size -= temp;
next += temp; next += temp;
......
...@@ -1161,7 +1161,7 @@ static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_i ...@@ -1161,7 +1161,7 @@ static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_i
buf += i; buf += i;
length -= i; length -= i;
i = snprintf (buf, length, " ("); i = scnprintf (buf, length, " (");
buf += i; buf += i;
length -= i; length -= i;
......
...@@ -72,6 +72,9 @@ extern int vsprintf(char *buf, const char *, va_list); ...@@ -72,6 +72,9 @@ extern int vsprintf(char *buf, const char *, va_list);
extern int snprintf(char * buf, size_t size, const char * fmt, ...) extern int snprintf(char * buf, size_t size, const char * fmt, ...)
__attribute__ ((format (printf, 3, 4))); __attribute__ ((format (printf, 3, 4)));
extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
__attribute__ ((format (printf, 3, 4)));
extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
extern int sscanf(const char *, const char *, ...) extern int sscanf(const char *, const char *, ...)
__attribute__ ((format (scanf,2,3))); __attribute__ ((format (scanf,2,3)));
......
...@@ -501,7 +501,7 @@ asmlinkage int printk(const char *fmt, ...) ...@@ -501,7 +501,7 @@ asmlinkage int printk(const char *fmt, ...)
/* Emit the output into the temporary buffer */ /* Emit the output into the temporary buffer */
va_start(args, fmt); va_start(args, fmt);
printed_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args); printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
va_end(args); va_end(args);
/* /*
......
...@@ -193,7 +193,7 @@ int bitmap_snprintf(char *buf, unsigned int buflen, ...@@ -193,7 +193,7 @@ int bitmap_snprintf(char *buf, unsigned int buflen,
word = i / BITS_PER_LONG; word = i / BITS_PER_LONG;
bit = i % BITS_PER_LONG; bit = i % BITS_PER_LONG;
val = (maskp[word] >> bit) & chunkmask; val = (maskp[word] >> bit) & chunkmask;
len += snprintf(buf+len, buflen-len, "%s%0*lx", sep, len += scnprintf(buf+len, buflen-len, "%s%0*lx", sep,
(chunksz+3)/4, val); (chunksz+3)/4, val);
chunksz = CHUNKSZ; chunksz = CHUNKSZ;
sep = ","; sep = ",";
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
/* /*
* Fri Jul 13 2001 Crutcher Dunnavant <crutcher+kernel@datastacks.com> * Fri Jul 13 2001 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
* - changed to provide snprintf and vsnprintf functions * - changed to provide snprintf and vsnprintf functions
* So Feb 1 16:51:32 CET 2004 Juergen Quade <quade@hsnr.de>
* - scnprintf and vscnprintf
*/ */
#include <stdarg.h> #include <stdarg.h>
...@@ -228,19 +230,22 @@ static char * number(char * buf, char * end, unsigned long long num, int base, i ...@@ -228,19 +230,22 @@ static char * number(char * buf, char * end, unsigned long long num, int base, i
} }
/** /**
* vsnprintf - Format a string and place it in a buffer * vsnprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into * @buf: The buffer to place the result into
* @size: The size of the buffer, including the trailing null space * @size: The size of the buffer, including the trailing null space
* @fmt: The format string to use * @fmt: The format string to use
* @args: Arguments for the format string * @args: Arguments for the format string
* *
* The return value is the number of characters which would be * The return value is the number of characters which would
* generated for the given input, excluding the trailing null, * be generated for the given input, excluding the trailing
* as per ISO C99. If the return is greater than or equal to * '\0', as per ISO C99. If you want to have the exact
* @size, the resulting string is truncated. * number of characters written into @buf as return value
* * (not including the trailing '\0'), use vscnprintf. If the
* Call this function if you are already dealing with a va_list. * return is greater than or equal to @size, the resulting
* You probably want snprintf instead. * string is truncated.
*
* Call this function if you are already dealing with a va_list.
* You probably want snprintf instead.
*/ */
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{ {
...@@ -481,6 +486,30 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ...@@ -481,6 +486,30 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
EXPORT_SYMBOL(vsnprintf); EXPORT_SYMBOL(vsnprintf);
/**
* vscnprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into
* @size: The size of the buffer, including the trailing null space
* @fmt: The format string to use
* @args: Arguments for the format string
*
* The return value is the number of characters which have been written into
* the @buf not including the trailing '\0'. If @size is <= 0 the function
* returns 0.
*
* Call this function if you are already dealing with a va_list.
* You probably want scnprintf instead.
*/
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
int i;
i=vsnprintf(buf,size,fmt,args);
return (i >= size) ? (size - 1) : i;
}
EXPORT_SYMBOL(vscnprintf);
/** /**
* snprintf - Format a string and place it in a buffer * snprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into * @buf: The buffer to place the result into
...@@ -506,12 +535,40 @@ int snprintf(char * buf, size_t size, const char *fmt, ...) ...@@ -506,12 +535,40 @@ int snprintf(char * buf, size_t size, const char *fmt, ...)
EXPORT_SYMBOL(snprintf); EXPORT_SYMBOL(snprintf);
/**
* scnprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into
* @size: The size of the buffer, including the trailing null space
* @fmt: The format string to use
* @...: Arguments for the format string
*
* The return value is the number of characters written into @buf not including
* the trailing '\0'. If @size is <= 0 the function returns 0. If the return is
* greater than or equal to @size, the resulting string is truncated.
*/
int scnprintf(char * buf, size_t size, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i = vsnprintf(buf, size, fmt, args);
va_end(args);
return (i >= size) ? (size - 1) : i;
}
EXPORT_SYMBOL(scnprintf);
/** /**
* vsprintf - Format a string and place it in a buffer * vsprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into * @buf: The buffer to place the result into
* @fmt: The format string to use * @fmt: The format string to use
* @args: Arguments for the format string * @args: Arguments for the format string
* *
* The function returns the number of characters written
* into @buf. Use vsnprintf or vscnprintf in order to avoid
* buffer overflows.
*
* Call this function if you are already dealing with a va_list. * Call this function if you are already dealing with a va_list.
* You probably want sprintf instead. * You probably want sprintf instead.
*/ */
...@@ -527,6 +584,10 @@ EXPORT_SYMBOL(vsprintf); ...@@ -527,6 +584,10 @@ EXPORT_SYMBOL(vsprintf);
* @buf: The buffer to place the result into * @buf: The buffer to place the result into
* @fmt: The format string to use * @fmt: The format string to use
* @...: Arguments for the format string * @...: Arguments for the format string
*
* The function returns the number of characters written
* into @buf. Use snprintf or scnprintf in order to avoid
* buffer overflows.
*/ */
int sprintf(char * buf, const char *fmt, ...) int sprintf(char * buf, const char *fmt, ...)
{ {
......
...@@ -829,7 +829,7 @@ static void atmarp_info(struct seq_file *seq, struct net_device *dev, ...@@ -829,7 +829,7 @@ static void atmarp_info(struct seq_file *seq, struct net_device *dev,
!clip_vcc || clip_vcc->encap ? "LLC" : "NULL", !clip_vcc || clip_vcc->encap ? "LLC" : "NULL",
(jiffies-(clip_vcc ? clip_vcc->last_use : entry->neigh->used))/HZ); (jiffies-(clip_vcc ? clip_vcc->last_use : entry->neigh->used))/HZ);
off = snprintf(buf, sizeof(buf) - 1, "%d.%d.%d.%d", NIPQUAD(entry->ip)); off = scnprintf(buf, sizeof(buf) - 1, "%d.%d.%d.%d", NIPQUAD(entry->ip));
while (off < 16) while (off < 16)
buf[off++] = ' '; buf[off++] = ' ';
buf[off] = '\0'; buf[off] = '\0';
......
...@@ -56,7 +56,7 @@ static ssize_t sel_read_enforce(struct file *filp, char *buf, ...@@ -56,7 +56,7 @@ static ssize_t sel_read_enforce(struct file *filp, char *buf,
return -ENOMEM; return -ENOMEM;
memset(page, 0, PAGE_SIZE); memset(page, 0, PAGE_SIZE);
length = snprintf(page, PAGE_SIZE, "%d", selinux_enforcing); length = scnprintf(page, PAGE_SIZE, "%d", selinux_enforcing);
if (length < 0) { if (length < 0) {
free_page((unsigned long)page); free_page((unsigned long)page);
return length; return length;
...@@ -142,7 +142,7 @@ static ssize_t sel_read_policyvers(struct file *filp, char *buf, ...@@ -142,7 +142,7 @@ static ssize_t sel_read_policyvers(struct file *filp, char *buf,
return -ENOMEM; return -ENOMEM;
memset(page, 0, PAGE_SIZE); memset(page, 0, PAGE_SIZE);
length = snprintf(page, PAGE_SIZE, "%u", POLICYDB_VERSION); length = scnprintf(page, PAGE_SIZE, "%u", POLICYDB_VERSION);
if (length < 0) { if (length < 0) {
free_page((unsigned long)page); free_page((unsigned long)page);
return length; return length;
...@@ -407,7 +407,7 @@ static ssize_t sel_write_access(struct file * file, char *buf, size_t size) ...@@ -407,7 +407,7 @@ static ssize_t sel_write_access(struct file * file, char *buf, size_t size)
if (length < 0) if (length < 0)
goto out2; goto out2;
length = snprintf(buf, PAYLOAD_SIZE, "%x %x %x %x %u", length = scnprintf(buf, PAYLOAD_SIZE, "%x %x %x %x %u",
avd.allowed, avd.decided, avd.allowed, avd.decided,
avd.auditallow, avd.auditdeny, avd.auditallow, avd.auditdeny,
avd.seqno); avd.seqno);
......
...@@ -99,7 +99,7 @@ int snd_iprintf(snd_info_buffer_t * buffer, char *fmt,...) ...@@ -99,7 +99,7 @@ int snd_iprintf(snd_info_buffer_t * buffer, char *fmt,...)
if (buffer->stop || buffer->error) if (buffer->stop || buffer->error)
return 0; return 0;
va_start(args, fmt); va_start(args, fmt);
res = vsnprintf(sbuffer, sizeof(sbuffer), fmt, args); res = vscnprintf(sbuffer, sizeof(sbuffer), fmt, args);
va_end(args); va_end(args);
if (buffer->size + res >= buffer->len) { if (buffer->size + res >= buffer->len) {
buffer->stop = 1; buffer->stop = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment