Statistics
| Branch: | Revision:

root @ 94befa45

# Date Author Comment
1e5b31e6 10/10/2012 04:13 am Peter A. G. Crosthwaite

qdev: allow multiple qdev_init_gpio_in() calls

Allow multiple qdev_init_gpio_in() calls for the one device. The first call will
define GPIOs 0-N-1, the next GPIOs N- ... . Allows different GPIOs to be handled
with different handlers. Needed when two levels of the QOM class heirachy both...

8120e714 10/10/2012 04:13 am Peter A. G. Crosthwaite

stellaris: Removed SSI mux

Removed the explicit SSI mux and wired the CS line directly up to the SSI
devices.

Signed-off-by: Peter A. G. Crosthwaite <>

a3578d4a 10/10/2012 04:13 am Peter A. G. Crosthwaite

hw: Added generic FIFO API.

Added a FIFO API that can be used to create and operate byte FIFOs.

Signed-off-by: Peter A. G. Crosthwaite <>

82a24990 10/10/2012 04:13 am Peter A. G. Crosthwaite

m25p80: Initial implementation of SPI flash device

Added device model for m25p80 style SPI flash family.

Signed-off-by: Peter A. G. Crosthwaite <>

929d1b52 10/10/2012 04:13 am Peter A. G. Crosthwaite

xilinx_spi: Initial impl. of Xilinx SPI controller

Device model for xilinx XPS SPI controller (v2.0)

Signed-off-by: Peter A. G. Crosthwaite <>

acd3b6be 10/10/2012 04:13 am Peter A. G. Crosthwaite

petalogix-ml605: added SPI controller with n25q128

Added SPI controller to the reference design, with two n25q128 spi-flashes
connected.

Signed-off-by: Peter A. G. Crosthwaite <>
Acked-by: Peter Maydell <>

94befa45 10/10/2012 04:13 am Peter A. G. Crosthwaite

xilinx_spips: Xilinx Zynq SPI cntrlr device model

Added device model for the Xilinx Zynq SPI controller (SPIPS).

Signed-off-by: Peter A. G. Crosthwaite <>
Acked-by: Peter Maydell <>

b4a76e84 10/10/2012 04:13 am Peter A. G. Crosthwaite

ssi: Support for multiple attached devices

Removed assertion that only one device is attached to the SSI bus.

When multiple devices are attached, all slaves have their transfer function
called for transfers. Each device is responsible for knowing whether or not its...

66530953 10/10/2012 04:13 am Peter A. G. Crosthwaite

ssi: Implemented CS behaviour

Added default CS behaviour for SSI slaves. SSI devices can set a property
to enable CS behaviour which will create a GPIO on the device which is the
CS. Tristating of the bus on SSI transfers is implemented.

Signed-off-by: Peter A. G. Crosthwaite <>...

74687e40 10/10/2012 04:13 am Peter A. G. Crosthwaite

ssi: Added create_slave_no_init()

Slave creation function that can be used to create an SSI slave without
qdev_init() being called. This give machine models a chance to set properties.

Signed-off-by: Peter A. G. Crosthwaite <>...

4bb26682 10/07/2012 09:42 pm Blue Swirl

Merge branch 'master' of git.qemu.org:/pub/git/qemu

  • 'master' of git.qemu.org:/pub/git/qemu:
    qemu-barrier: Fix compilation on i386 hosts
f1829782 10/07/2012 09:07 pm Aurelien Jarno

qemu-barrier: Fix compilation on i386 hosts

Commit 1d31fca470648ec66afd8743491bfb5846306341 tried to fix bug
introduced by 610b823ef66b993660f1ab1447a769f190e4f3b3 by including
qemu-common.h, which breaks the build further.

Include compiler.h instead, as suggested by Blue Swirl....

690995a6 10/07/2012 07:39 pm Richard Henderson

target-sparc: Use movcond for FMOV*R

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

b09b2fd3 10/07/2012 07:39 pm Richard Henderson

target-sparc: Cleanup "global" temporary allocation

There are 6 temporaries that disas_sparc_insn relies on having been
allocated. Now that they are no longer referenced across branches,
they need not be allocated as local temps.

Move the allocation/free of these temporaries to make it clear that...

fe1755cb 10/07/2012 07:39 pm Richard Henderson

target-sparc: Fall through from not-taken trap

Now that we've cleaned up global temporary allocation, we can
continue translating the fallthru path of a conditional trap.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

2a484ecf 10/07/2012 07:39 pm Richard Henderson

target-sparc: Optimize conditionals using SUBCC

Aka "normal" comparisons. We now have the infrastructure to
pass back non-boolean results from gen_compare. This will
automatically get used by both branches and conditional moves.

Signed-off-by: Richard Henderson <>...

c28ae41e 10/07/2012 07:39 pm Richard Henderson

target-sparc: Move sdivx and udivx out of line

The branches around the exception are maintaining an otherwise
unnecessary use of local temps for the cpu destination.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

bd49ed41 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy Tcc

Share more code between unconditional and conditional paths.

Move the computation of the trap number into the conditional BB;
avoid using temporaries that have gone out of scope (cpu_tmp32)
or rely on local temps (cpu_dst).

Fully fold the exception number when the trap number is %g0+imm....

a2ea4aa9 10/07/2012 07:39 pm Richard Henderson

target-sparc: Move taddcctv and tsubcctv out of line

The branches around the exception are maintaining an otherwise
unnecessary use of local temps for the cpu destination.

Note that gen_op_t{add,sub}_cc were identical to gen_op_{add,sub}_cc.

Signed-off-by: Richard Henderson <>...

6cb675b0 10/07/2012 07:39 pm Richard Henderson

target-sparc: Use movcond in mulscc

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

7e480893 10/07/2012 07:39 pm Richard Henderson

target-sparc: Use DisasCompare and movcond in FMOVR, FMOVCC

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

f52879b4 10/07/2012 07:39 pm Richard Henderson

target-sparc: Use DisasCompare and movcond in MOVCC

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

c33f80f5 10/07/2012 07:39 pm Richard Henderson

target-sparc: Use DisasCompare and movcond in MOVR

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

61316742 10/07/2012 07:39 pm Richard Henderson

target-sparc: Use movcond in gen_generic_branch

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

934da7ee 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy save_npc interface

Use the cpu_cond global register directly instead of passing it down.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

2e655fe7 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy gen_generic_branch interface

The arguments passed are always the same.
Pass down just DisasContext instead.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

416fcaea 10/07/2012 07:39 pm Richard Henderson

target-sparc: Introduce DisasCompare and functions to generate it

For the moment gen_cond et al retain their existing interface,
using setcond to turn a (potential) comparison back into a boolean.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

3a49e759 10/07/2012 07:39 pm Richard Henderson

target-sparc: Use DisasCompare in Tcc

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

dee8913c 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy flush_cond interface

We always pass cpu_cond to the cond parameter. Use that global
register directly instead of passing it down.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

5b12f1e8 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy gen_trap_ifnofpu interface

We always pass cpu_cond to the cond parameter. Use that global
register directly instead of passing it down.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

66442b07 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy save_state interface

Use the cpu_cond global register directly instead of passing it down.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

13a6dd00 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy gen_mov_pc_npc interface

Use the cpu_cond global register directly instead of passing it down.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

76a23ca0 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy cpu_dump_state

We don't really need to be told that %g are general register, etc.
Issue a trailing newline to separate blocks.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

b884fc5e 10/07/2012 07:39 pm Richard Henderson

target-sparc: Make CPU_LOG_INT useful by default

No need for ifdefs when the log mask does just as well.
No need to print pc/npc when we're dumping the whole cpu state.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

d4a288ef 10/07/2012 07:39 pm Richard Henderson

target-sparc: Tidy do_branch interfaces

We always pass cpu_cond to the r_cond parameter. Use that global
register directly instead of passing it down.

Signed-off-by: Richard Henderson <>
Signed-off-by: Blue Swirl <>

d8382011 10/07/2012 07:36 pm Stefan Weil

tcg: Remove redundant pointer from TCGContext

The pointer entry 'temps' always refers to the array entry 'static_temps'.
Removing the pointer and renaming 'static_temps' to 'temps' reduces the
size of TCGContext (4 or 8 byte) and allows better code generation....

046dbab9 10/06/2012 07:54 pm Aurelien Jarno

Merge branch 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm

  • 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm:
    target-arm: Drop unused DECODE_CPREG_CRN macro
    target-arm: use deposit instead of hardcoded version...
048d3612 10/06/2012 07:54 pm Aurelien Jarno

Merge branch 'trivial-patches' of git://github.com/stefanha/qemu

  • 'trivial-patches' of git://github.com/stefanha/qemu:
    versatilepb: Use symbolic indices for ARM PIC
    qdev: kill bogus comment
    qemu-barrier: Fix compiler version check for future gcc versions...
6b2f90fb 10/06/2012 07:51 pm Aurelien Jarno

Merge branch 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf

  • 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf: (35 commits)
    PPC: KVM: Fix BAT put
    PPC: e500: Only expose even TLB sizes in initial TLB
    ppc/pseries: Reset VPA registration on CPU reset...
1d31fca4 10/06/2012 07:49 pm Stefan Weil

qemu-barrier: Fix compilation on i386 hosts

Commit 610b823ef66b993660f1ab1447a769f190e4f3b3 uses QEMU_GNUC_PREREQ
on i386 hosts.

That macro is defined in qemu-common.h which is not always included
before qemu-barrier.h, so compilation on i386 hosts was broken....

0aed257f 10/06/2012 07:48 pm Richard Henderson

tcg: Add TCG_COND_NEVER, TCG_COND_ALWAYS

There are several cases that can be handled easier inside both
translators and code generators if we have out-of-band values
for conditions. It's easy enough to handle ALWAYS and NEVER in
the natural way inside the tcg middle-end....

d1e321b8 10/06/2012 07:48 pm Richard Henderson

tcg: Add tcg_high_cond

The table that was recently added for hppa is generally usable.
And with the renumbering of the TCG_COND constants it's not too
difficult to compute rather than have a table.

Signed-off-by: Richard Henderson <>
Signed-off-by: Aurelien Jarno <>

95fa01fa 10/06/2012 07:48 pm Aurelien Jarno

ppc/prep: use the new pci_vga_init() function

As a bonus it allows new vga card types (including none).

Acked-by: Andreas Färber <>
Signed-off-by: Aurelien Jarno <>

1ddcae82 10/06/2012 07:48 pm Aurelien Jarno

ppc/pSeries: use the new pci_vga_init() function

Keep the case to prevent some vga card to be selected.

Cc: Alexander Graf <>
Cc: David Gibson <>
Signed-off-by: Aurelien Jarno <>

f2898771 10/06/2012 07:48 pm Aurelien Jarno

sun/sun4u: use the new pci_vga_init() function

As a bonus it allows new vga card types (including none).

Acked-by: Blue Swirl <>
Signed-off-by: Aurelien Jarno <>

16094b75 10/06/2012 07:48 pm Aurelien Jarno

pc: use the new pci_vga_init() and isa_vga_init() functions

The CONFIG_SPICE is now tested in vl.c and thus not needed anymore.

Cc: Anthony Liguori <>
Signed-off-by: Aurelien Jarno <>

f642dfce 10/06/2012 07:48 pm Aurelien Jarno

mips/r4k: use the new is_vga_init() function

Signed-off-by: Aurelien Jarno <>

457ebdcd 10/06/2012 07:48 pm Aurelien Jarno

vga: cleanup after isa_vga_init() and pci_vga_init() conversion

Now that all machines call isa_vga_init() or pci_vga_init(), some unused
code can be removed.

Cc: Anthony Liguori <>
Signed-off-by: Aurelien Jarno <>

bcc66562 10/06/2012 07:48 pm Richard Henderson

tcg: Add is_unsigned_cond

Before we rearrange the TCG_COND enumeration, add a predicate for
the (single) use of comparisons vs TCGCond.

Signed-off-by: Richard Henderson <>
Signed-off-by: Aurelien Jarno <>

879049a3 10/06/2012 07:48 pm Aurelien Jarno

vl.c: check for qxl availability

Check for qxl availability in vl.c. This will allow to remove #ifdef
CONFIG_SPICE .. #endif later in this series

Cc: Anthony Liguori <>
Cc: Gerd Hoffmann <>
Signed-off-by: Aurelien Jarno <>

3605ded5 10/06/2012 07:48 pm Aurelien Jarno

vl.c: default to std if cirrus is not available

Signed-off-by: Aurelien Jarno <>

129d42fb 10/06/2012 07:48 pm Aurelien Jarno

pci: add a pci_vga_init() function

This function create a PCI VGA device according to the value of
vga_interface_type. It returns a PCIDevice (and not a DeviceState).

Cc: Anthony Liguori <>
Signed-off-by: Aurelien Jarno <>

14e7a645 10/06/2012 07:48 pm Aurelien Jarno

isa: add a isa_vga_init() function

This function create a ISA VGA device according to the value of
vga_interface_type. It returns a ISADevice (and not a DeviceState).

Signed-off-by: Aurelien Jarno <>

9c59864d 10/06/2012 07:48 pm Aurelien Jarno

mips/malta: use the new pci_vga_init() function

Signed-off-by: Aurelien Jarno <>

606f90cc 10/06/2012 07:48 pm Aurelien Jarno

alpha: use the new pci_vga_init() function

This remove the fallback to std-vga in case, as availability of the
requested vga device is now tested in vl.c, and returns an error message
to the user.

Acked-by: Richard Henderson <>
Signed-off-by: Aurelien Jarno <>

e7a2e96d 10/06/2012 07:48 pm Aurelien Jarno

ppc/newworld: use the new pci_vga_init() function

As a bonus it allows new vga card types (including none).

Cc: Alexander Graf <>
Signed-off-by: Aurelien Jarno <>

3e20ad3a 10/06/2012 07:48 pm Aurelien Jarno

ppc/oldworld: use the new pci_vga_init() function

As a bonus it allows new vga card types (including none).

Cc: Alexander Graf <>
Signed-off-by: Aurelien Jarno <>

a1e47211 10/06/2012 07:48 pm Aurelien Jarno

vga: rename pci_vga_init() into pci_std_vga_init()

This better explains what is this function about. Adjust all callers.

Cc: Alexander Graf <>
Cc: Andreas Färber <>
Cc: David Gibson <>
Cc: Anthony Liguori <>...

6405c864 10/06/2012 07:48 pm Aurelien Jarno

vga: rename isa_vga_init() to isa_std_vga_init()

This better explains what is this function about. Adjust all callers.

Cc: Anthony Liguori <>
Signed-off-by: Aurelien Jarno <>

36b7f27d 10/06/2012 07:48 pm Aurelien Jarno

vl.c: convert *vga_enabled functions to QOM

And get rid of qdev_exists().

Signed-off-by: Aurelien Jarno <>

626cd050 10/06/2012 07:47 pm Aurelien Jarno

tcg: remove obsolete jmp op

The TCG jmp operation doesn't really make sense in the QEMU context, it
is unused, it is not implemented by some targets, and it is wrongly
implemented by some others.

This patch simply removes it.

Reviewed-by: Richard Henderson <>...

f783cb22 10/06/2012 01:22 pm Aurelien Jarno

target-xtensa: de-optimize EXTUI

Now that "and" with 0xff, 0xffff and 0xffffffff and "shr" with 0 shift
are optimized in tcg/tcg-op.h there is no need to do it in
target-xtensa/translate.c.

Acked-by: Max Filippov <>
Signed-off-by: Aurelien Jarno <>

c9159fe9 10/06/2012 12:07 am Stefan Weil

Remove libhw

The entries for libhw* are no longer needed in .gitignore.

There is also no longer a difference between common-obj-y and
hw-obj-y, so one of those two macros is sufficient.

Signed-off-by: Stefan Weil <>
Signed-off-by: Anthony Liguori <>

00e3ab2d 10/05/2012 05:04 pm Aurelien Jarno

target-arm: mark a few integer helpers const and pure

Signed-off-by: Aurelien Jarno <>
Signed-off-by: Peter Maydell <>

d593c48e 10/05/2012 05:04 pm Aurelien Jarno

target-arm: use deposit instead of hardcoded version

Use the deposit op instead of and hardcoded bit field insertion. It
allows the host to emit the corresponding instruction if available.

Signed-off-by: Aurelien Jarno <>
Signed-off-by: Peter Maydell <>

1273d9ca 10/05/2012 05:04 pm Peter Maydell

target-arm: Drop unused DECODE_CPREG_CRN macro

This macro snuck through code review despite being unused; drop it.

Signed-off-by: Peter Maydell <>

f2617cfc 10/05/2012 05:04 pm Peter Maydell

target-arm: Reinstate display of VFP registers in cpu_dump_state

Reinstate the display of VFP registers in cpu_dump_state(), if
the CPU has them (this code had been #if 0'd out a for a long time).
We drop the attempt ot display the values as floating point, since...

66c374de 10/05/2012 05:04 pm Aurelien Jarno

target-arm: use globals for CC flags

Use globals for CC flags instead of loading/storing them each they are
accessed. This allows some optimizations to be performed by the TCG
optimization passes.

Signed-off-by: Aurelien Jarno <>
Signed-off-by: Peter Maydell <>

72485ec4 10/05/2012 05:04 pm Aurelien Jarno

target-arm: convert add_cc and sub_cc helpers to TCG

Now that the setcond TCG op is available, it's possible to replace
add_cc and sub_cc helpers by TCG code. The code generated by TCG is
actually very close to the one generated by GCC for the helper, and...

365af80e 10/05/2012 05:04 pm Aurelien Jarno

target-arm: convert sar, shl and shr helpers to TCG

Now that the movcond TCG op is available, it's possible to replace
shl and shr helpers by TCG code. The code generated by TCG is slightly
longer than the code generated by GCC for the helper but is still worth...

6fd2a026 10/05/2012 05:04 pm Peter Maydell

cpu_dump_state: move DUMP_FPU and DUMP_CCOP flags from x86-only to generic

Move the DUMP_FPU and DUMP_CCOP flags for cpu_dump_state() from being
x86-specific flags to being generic ones. This allows us to drop some
TARGET_I386 ifdefs in various places, and means that we can (potentially)...

02cd521f 10/05/2012 04:50 pm Stefan Weil

versatilepb: Use symbolic indices for ARM PIC

It is more readable, and all other code does it like that, too.

Signed-off-by: Stefan Weil <>
Reviewed-by: Peter Maydell <>
Signed-off-by: Stefan Hajnoczi <>

c36b7de6 10/05/2012 04:49 pm Eduardo Habkost

qdev: kill bogus comment

When the DeviceInfo code was removed, the comment describing
qdev_subclass_init() was left in the code by mistake. Remove it.

Cc:
Signed-off-by: Eduardo Habkost <>
Signed-off-by: Stefan Hajnoczi <>

8e7e2b14 10/05/2012 04:48 pm Stefan Weil

qemu-barrier: Fix compiler version check for future gcc versions

The current check will give a wrong result for gcc-5.x with x < 4.
Using QEMU_GNUC_PREREQ is simpler and fixes that issue.

Signed-off-by: Stefan Weil <>
Signed-off-by: Stefan Hajnoczi <>

da665c99 10/05/2012 04:17 pm Stefan Weil

hw: Add missing 'static' attribute for QEMUMachine

It was missing for leon3 and mips_fulong2e.

Signed-off-by: Stefan Weil <>
Reviewed-by: Andreas Färber <>
Signed-off-by: Stefan Hajnoczi <>

4d5b97da 10/05/2012 04:10 pm Amos Kong

cleanup useless return sentence

This patch cleans up return sentences in the end of void functions.

Reported-by: Paolo Bonzini <>
Signed-off-by: Amos Kong <>
Signed-off-by: Stefan Hajnoczi <>

b6db4aca 10/05/2012 04:02 pm Paolo Bonzini

rtc: fix overflow in mktimegm

When setting a date in 1980, Linux is actually disregarding the century
byte and setting the year to 2080. This causes a year-2038 overflow
in mktimegm. Fix this by doing the days-to-seconds computation in
64-bit math.

Reported-by: Lucas Meneghel Rodrigues <>...

e67edb94 10/05/2012 04:02 pm Paolo Bonzini

rtc: map CMOS index 0x37 to 0x32 on read and writes

QEMU's attempt to implement the century byte cover two possible places
for the byte. A common one on modern chipsets is 0x32, but QEMU also
stores the value in 0x37 (apparently for IBM PS/2 compatibility---it's...

b8994faf 10/05/2012 04:02 pm Paolo Bonzini

rtc: implement century byte

Implement the century byte in the RTC emulation, and test that it works.
This leads to some annoying compatibility code because we need to treat
a value of 2000 for the base_year property as "use the century byte
properly" (which would be a value of 0)....

e0fea6b1 10/05/2012 04:02 pm Paolo Bonzini

qtest: implement QTEST_STOP

It is quite difficult to debug qtest test cases without extra wrapper
scripts for QEMU or similar. This patch adds a simple environment
variable-based trigger that sends a STOP signal to the QEMU instance
under test, before attempting to connect to its QMP session....

610b823e 10/05/2012 04:00 pm Stefan Weil

qemu-barrier: Fix compiler version check for future gcc versions

The current check will give a wrong result for gcc-5.x with x < 4.
Using QEMU_GNUC_PREREQ is simpler and fixes that issue.

Signed-off-by: Stefan Weil <>
Signed-off-by: Anthony Liguori <>

2e679780 10/05/2012 03:58 pm Jim Meyering

libcacard/vcard_emul_nss: use pstrcpy in place of strncpy

Replace strncpy+NUL-terminate use with use of pstrcpy.
This requires linking with cutils.o (or else vssclient doesn't link),
so add that in the Makefile.

Acked-by: Alon Levy <>
Signed-off-by: Jim Meyering <>...

3cda3462 10/05/2012 03:58 pm Jim Meyering

acpi: remove strzcpy (strncpy-identical) function; just use strncpy

Adjust all uses s/strzcpy/strncpy/ and mark these uses
of strncpy as "ok".

Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

00ea1881 10/05/2012 03:58 pm Jim Meyering

qcow2: mark this file's sole strncpy use as justified

Acked-by: Kevin Wolf <>
Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

9310b9be 10/05/2012 03:58 pm Jim Meyering

hw/r2d: add comment: this strncpy use is ok

Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

9b9e3ec1 10/05/2012 03:58 pm Jim Meyering

doc: update HACKING wrt strncpy/pstrcpy

Reword the section on strncpy: its NUL-filling is important
in some cases. Mention that pstrcpy's signature is different.

Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

a79b5f8b 10/05/2012 03:58 pm Jim Meyering

hw/9pfs: avoid buffer overrun

v9fs_add_dir_node and qemu_v9fs_synth_add_file used strncpy
to form node->name, which requires NUL-termination, but
strncpy does not ensure NUL-termination.
Use pstrcpy, which does.

Acked-by: Aneesh Kumar K.V <>...

1044dc11 10/05/2012 03:58 pm Jim Meyering

lm32: avoid buffer overrun

Actually do what the comment says, using pstrcpy NUL-terminate:
strncpy does not always do that.

Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

3eadc68e 10/05/2012 03:58 pm Jim Meyering

os-posix: avoid buffer overrun

os_set_proc_name: Use pstrcpy, in place of strncpy and the
ineffectual preceding assignment: name[sizeof(name) - 1] = 0;

Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

ae215068 10/05/2012 03:58 pm Jim Meyering

ppc: avoid buffer overrun: use pstrcpy, not strncpy

A terminal NUL is required by caller's use of strchr.
It's better not to use strncpy at all, since there is no need
to zero out hundreds of trailing bytes for each iteration.

Signed-off-by: Jim Meyering <>...

900cfbca 10/05/2012 03:58 pm Jim Meyering

linux-user: remove two unchecked uses of strdup

Remove two uses of strdup (use g_path_get_basename instead),
and add a comment that this strncpy use is ok.

Reviewed-by: Peter Maydell <>
Signed-off-by: Jim Meyering <>...

5847d9e1 10/05/2012 03:58 pm Jim Meyering

ui/vnc: simplify and avoid strncpy

Don't bother with strncpy. There's no need for its zero-fill.
Use g_strndup in place of g_malloc+strncpy+NUL-terminate.

Reviewed-by: Peter Maydell <>
Signed-off-by: Jim Meyering <>...

e5fda038 10/05/2012 03:58 pm Jim Meyering

bt: replace fragile snprintf use and unwarranted strncpy

In bt_hci_name_req a failed snprintf could return len larger than
sizeof(params.name), which means the following memset call would
have a "length" value of (size_t)-1, -2, etc... Sounds scary.
But currently, one can deduce that there is no problem:...

9238c209 10/05/2012 03:58 pm Jim Meyering

virtio-9p: avoid unwarranted uses of strncpy

In all of these cases, the uses of strncpy were unnecessary, since
at each point of use we know that the NUL-terminated source bytes
fit in the destination buffer. Use memcpy in place of strncpy.

Acked-by: Aneesh Kumar K.V <>...

9d055d8a 10/05/2012 03:58 pm Jim Meyering

vscsi: avoid unwarranted strncpy

Don't use strncpy when the source string is known to fit
in the destination buffer. Use equivalent memcpy.
We could even use strcpy, here, but some static analyzers
warn about that, so don't add new uses.

Acked-by: David Gibson <>...

1ab516ed 10/05/2012 03:58 pm Jim Meyering

qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name

NUL-termination of the .ifr_name field is not required, but is fine
(and preferable to using strncpy and leaving the reader to wonder),
since the first thing the linux kernel does is to clear the last byte....

bfad6739 10/05/2012 03:58 pm Jim Meyering

sparc: use g_strdup in place of unchecked strdup

This avoids a NULL-deref upon strdup failure.
Also update matching free to g_free.

Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

c2cba3d9 10/05/2012 03:58 pm Jim Meyering

block: avoid buffer overrun by using pstrcpy, not strncpy

Also, use PATH_MAX, rather than the arbitrary 1024.
Using PATH_MAX is more consistent with other filename-related
variables in this file, like backing_filename and tmp_filename.

Acked-by: Kevin Wolf <>...

3178e275 10/05/2012 03:58 pm Jim Meyering

sheepdog: avoid a few buffer overruns

  • parse_vdiname: Use pstrcpy, not strncpy, when the destination
    buffer must be NUL-terminated.
  • sd_open: Likewise, avoid buffer overrun.
  • do_sd_create: Likewise. Leave the preceding memset, since
    pstrcpy does not NUL-fill, and filename needs that....
d66f8e7b 10/05/2012 03:58 pm Jim Meyering

vmdk: relative_path: use pstrcpy in place of strncpy

Avoid strncpy+manual-NUL-terminate. Use pstrcpy instead.

Acked-by: Kevin Wolf <>
Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>