direct-io.hg

changeset 13727:bd69e83b65ea

ia64, ppc: Remove uses of sprintf().
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir@xensource.com>
date Tue Jan 30 16:14:16 2007 +0000 (2007-01-30)
parents 300c47bec138
children 9578ae319874
files xen/arch/ia64/linux-xen/perfmon.c xen/arch/ia64/linux-xen/setup.c xen/arch/ia64/linux-xen/sn/kernel/io_init.c xen/arch/ia64/linux-xen/unaligned.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/gdbstub.c xen/arch/ia64/xen/xensetup.c xen/arch/powerpc/domain_build.c
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/perfmon.c	Tue Jan 30 16:09:16 2007 +0000
     1.2 +++ b/xen/arch/ia64/linux-xen/perfmon.c	Tue Jan 30 16:14:16 2007 +0000
     1.3 @@ -2305,7 +2305,7 @@ pfm_alloc_fd(struct file **cfile)
     1.4  	inode->i_uid  = current->fsuid;
     1.5  	inode->i_gid  = current->fsgid;
     1.6  
     1.7 -	sprintf(name, "[%lu]", inode->i_ino);
     1.8 +	snprintf(name, sizeof(name), "[%lu]", inode->i_ino);
     1.9  	this.name = name;
    1.10  	this.len  = strlen(name);
    1.11  	this.hash = inode->i_ino;
     2.1 --- a/xen/arch/ia64/linux-xen/setup.c	Tue Jan 30 16:09:16 2007 +0000
     2.2 +++ b/xen/arch/ia64/linux-xen/setup.c	Tue Jan 30 16:14:16 2007 +0000
     2.3 @@ -550,7 +550,7 @@ show_cpuinfo (struct seq_file *m, void *
     2.4  	switch (c->family) {
     2.5  	      case 0x07:	memcpy(family, "Itanium", 8); break;
     2.6  	      case 0x1f:	memcpy(family, "Itanium 2", 10); break;
     2.7 -	      default:		sprintf(family, "%u", c->family); break;
     2.8 +	      default:		snprintf(family, sizeof(family), "%u", c->family); break;
     2.9  	}
    2.10  
    2.11  	/* build the feature string: */
    2.12 @@ -572,7 +572,7 @@ show_cpuinfo (struct seq_file *m, void *
    2.13  		/* print unknown features as a hex value: */
    2.14  		if (sep)
    2.15  			*cp++ = sep;
    2.16 -		sprintf(cp, " 0x%lx", mask);
    2.17 +		snprintf(cp, sizeof(features) - (cp - features), " 0x%lx", mask);
    2.18  	}
    2.19  
    2.20  	seq_printf(m,
     3.1 --- a/xen/arch/ia64/linux-xen/sn/kernel/io_init.c	Tue Jan 30 16:09:16 2007 +0000
     3.2 +++ b/xen/arch/ia64/linux-xen/sn/kernel/io_init.c	Tue Jan 30 16:14:16 2007 +0000
     3.3 @@ -754,7 +754,7 @@ void sn_generate_path(struct pci_bus *pc
     3.4  	geoid = cnodeid_get_geoid(cnode);
     3.5  	moduleid = geo_module(geoid);
     3.6  
     3.7 -	sprintf(address, "module_%c%c%c%c%.2d",
     3.8 +	snprintf(address, 15, "module_%c%c%c%c%.2d",
     3.9  		'0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
    3.10  		'0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
    3.11  		'0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
    3.12 @@ -764,7 +764,7 @@ void sn_generate_path(struct pci_bus *pc
    3.13  	bricktype = MODULE_GET_BTYPE(moduleid);
    3.14  	if ((bricktype == L1_BRICKTYPE_191010) ||
    3.15  	    (bricktype == L1_BRICKTYPE_1932))
    3.16 -			sprintf(address, "%s^%d", address, geo_slot(geoid));
    3.17 +			snprintf(address, 15+8, "%s^%d", address, geo_slot(geoid));
    3.18  }
    3.19  #endif
    3.20  
     4.1 --- a/xen/arch/ia64/linux-xen/unaligned.c	Tue Jan 30 16:09:16 2007 +0000
     4.2 +++ b/xen/arch/ia64/linux-xen/unaligned.c	Tue Jan 30 16:14:16 2007 +0000
     4.3 @@ -1792,7 +1792,7 @@ printk("ia64_handle_unaligned: called, n
     4.4  			char buf[200];	/* comm[] is at most 16 bytes... */
     4.5  			size_t len;
     4.6  
     4.7 -			len = sprintf(buf, "%s(%d): unaligned access to 0x%016lx, "
     4.8 +			len = snprintf(buf, sizeof(buf), "%s(%d): unaligned access to 0x%016lx, "
     4.9  				      "ip=0x%016lx\n\r", current->comm, current->pid,
    4.10  				      ifa, regs->cr_iip + ipsr->ri);
    4.11  			/*
     5.1 --- a/xen/arch/ia64/xen/domain.c	Tue Jan 30 16:09:16 2007 +0000
     5.2 +++ b/xen/arch/ia64/xen/domain.c	Tue Jan 30 16:14:16 2007 +0000
     5.3 @@ -1124,7 +1124,7 @@ int construct_dom0(struct domain *d,
     5.4  		panic("can't allocate start info page");
     5.5  	si = page_to_virt(start_info_page);
     5.6  	memset(si, 0, PAGE_SIZE);
     5.7 -	sprintf(si->magic, "xen-%i.%i-ia64",
     5.8 +	snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-ia64",
     5.9  		xen_major_version(), xen_minor_version());
    5.10  	si->nr_pages     = max_pages;
    5.11  	si->flags = SIF_INITDOMAIN|SIF_PRIVILEGED;
     6.1 --- a/xen/arch/ia64/xen/gdbstub.c	Tue Jan 30 16:09:16 2007 +0000
     6.2 +++ b/xen/arch/ia64/xen/gdbstub.c	Tue Jan 30 16:14:16 2007 +0000
     6.3 @@ -289,13 +289,13 @@ gdb_arch_read_reg(unsigned long regnum, 
     6.4  	}
     6.5  
     6.6  	dbg_printk("Register read regnum = 0x%lx, val = 0x%lx\n", regnum, reg);	
     6.7 -	sprintf(buf, "%.08lx", swab64(reg));
     6.8 +	snprintf(buf, sizeof(buf), "%.08lx", swab64(reg));
     6.9  out:
    6.10  	return gdb_send_reply(buf, ctx);
    6.11  
    6.12  out_err:
    6.13  	dbg_printk("Register read unsupported regnum = 0x%lx\n", regnum);
    6.14 -	sprintf(buf, "%s", "x");
    6.15 +	safe_strcpy(buf, "x");
    6.16  	goto out;
    6.17  }
    6.18  #else
    6.19 @@ -756,19 +756,19 @@ gdb_arch_read_reg(unsigned long regnum, 
    6.20  	if (arg.error > 0) {
    6.21  		// notify gdb that this register is not supported.
    6.22  		// see fetch_register_using_p() in gdb/remote.c.
    6.23 -		sprintf(buf, "%s", "x");
    6.24 +		safe_strcpy(buf, "x");
    6.25  	} else if (IA64_FR0_REGNUM <= regnum && regnum <= IA64_FR0_REGNUM + 127) {
    6.26 -		sprintf(buf, "%.016lx", swab64(freg.u.bits[0]));
    6.27 -		sprintf(buf + 16, "%.016lx", swab64(freg.u.bits[1]));
    6.28 +		snprintf(buf, sizeof(buf), "%.016lx", swab64(freg.u.bits[0]));
    6.29 +		snprintf(buf + 16, sizeof(buf) - 16, "%.016lx", swab64(freg.u.bits[1]));
    6.30  	} else {
    6.31 -		sprintf(buf, "%.016lx", swab64(reg));
    6.32 +		snprintf(buf, sizeof(buf), "%.016lx", swab64(reg));
    6.33  	}
    6.34  out:
    6.35  	return gdb_send_reply(buf, ctx);
    6.36  
    6.37  out_err:
    6.38  	dbg_printk("Register read unsupported regnum = 0x%lx\n", regnum);
    6.39 -	sprintf(buf, "%s", "E0");
    6.40 +	safe_strcpy(buf, "E0");
    6.41  	goto out;
    6.42  }
    6.43  #endif
     7.1 --- a/xen/arch/ia64/xen/xensetup.c	Tue Jan 30 16:09:16 2007 +0000
     7.2 +++ b/xen/arch/ia64/xen/xensetup.c	Tue Jan 30 16:14:16 2007 +0000
     7.3 @@ -551,10 +551,10 @@ void arch_get_xen_caps(xen_capabilities_
     7.4      int major = xen_major_version();
     7.5      int minor = xen_minor_version();
     7.6  
     7.7 -    p += sprintf(p,"xen-%d.%d-ia64 ", major, minor);
     7.8 +    p += snprintf(p,sizeof(info), "xen-%d.%d-ia64 ", major, minor);
     7.9  
    7.10      if (vmx_enabled)
    7.11 -        p += sprintf(p,"hvm-%d.%d-ia64 ", major, minor);
    7.12 +        p += snprintf(p,sizeof(info) - (p - info),"hvm-%d.%d-ia64 ", major, minor);
    7.13  
    7.14      *(p-1) = 0;
    7.15  
     8.1 --- a/xen/arch/powerpc/domain_build.c	Tue Jan 30 16:09:16 2007 +0000
     8.2 +++ b/xen/arch/powerpc/domain_build.c	Tue Jan 30 16:14:16 2007 +0000
     8.3 @@ -185,7 +185,7 @@ int construct_dom0(struct domain *d,
     8.4      si = (start_info_t *)(rma_addr(&d->arch, RMA_START_INFO) + rma);
     8.5      printk("xen_start_info: %p\n", si);
     8.6  
     8.7 -    sprintf(si->magic, "xen-%i.%i-powerpc%d%s",
     8.8 +    snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-powerpc%d%s",
     8.9              xen_major_version(), xen_minor_version(), BITS_PER_LONG, "HV");
    8.10      si->flags = SIF_PRIVILEGED | SIF_INITDOMAIN;
    8.11