[libvirt] [PATCH 2/2] Introduce safewrite_str
Daniel P. Berrange
berrange at redhat.com
Tue Feb 23 13:19:38 UTC 2016
On Thu, Feb 18, 2016 at 07:40:12AM -0500, John Ferlan wrote:
>
>
> On 02/12/2016 08:59 AM, Ján Tomko wrote:
> > Just like safewrite, but calls strlen first to figure out
> > the length of the string.
> > ---
> > src/conf/virchrdev.c | 2 +-
> > src/libvirt_private.syms | 1 +
> > src/lxc/lxc_process.c | 4 ++--
> > src/network/leaseshelper.c | 2 +-
> > src/openvz/openvz_conf.c | 15 ++++++---------
> > src/qemu/qemu_domain.c | 2 +-
> > src/util/vircommand.c | 4 ++--
> > src/util/virfile.c | 9 ++++++++-
> > src/util/virfile.h | 1 +
> > src/util/virlog.c | 6 +++---
> > src/util/virpidfile.c | 4 ++--
> > src/util/virxml.c | 17 ++++++-----------
> > tools/vsh.c | 4 +---
> > 13 files changed, 35 insertions(+), 36 deletions(-)
> >
>
> Conflicted about this one - the difference between the two appears to be
> 'safewrite' will write a some length of a string (e.g. a counted length)
> while safewrite_str writes the entire string. To make things more
> interesting some safewrite calls use sizeof instead of strlen, but in
> reality are just writing everything in the buffer.
>
> So, perhaps 'safewrite_all' or 'safewrite_full' better describes the new
> functionality?
I don't think we need any new function actually.
Just add this to existing safewrite() method:
if (len == -1)
len = strlen(data)
and then update the callers which pass a NULL terminated string
to just pass -1. This matches our behaviour with virBuffer APIs
which acccept a length of -1.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list