Re: [PATCH 2/2] Introduce safewrite_str

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]