[libvirt] [PATCH] Introduce virStrncpy.

Paolo Bonzini bonzini at gnu.org
Tue Sep 22 16:49:51 UTC 2009


> Unfortunately that's not possible in the case of virStrcpyStatic().  Because
> virStrcpyStatic() does a sizeof(dest), you have to have the original char
> foo[123], not a char *, to get something meaningful.  That means that it has to
> either be a macro or not exist at all.  (I could be convinced of the latter, but
> I found it convenient when converting a number of these locations)
>
> I could make virStrcpy a small function, though.

Yes, that would be quite nice.  It would remove the multiple-evaluation 
problem from virStrcpyStatic too.

In the followup I'd also like to have macro arguments parenthesized:

#define virStrcpyStatic(dest, src) \
   virStrcpy((dest), (src), sizeof(dest))

I don't remember off the top of my head the case in which that would be 
a problem (since these are just function arguments), but I'm sure Jim 
Meyering could enlighten us. ;-)

Paolo




More information about the libvir-list mailing list