mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
src: Make virStr*cpy*() functions return an int
Currently, the functions return a pointer to the destination buffer on success or NULL on failure. Not only does this kind of error handling look quite alien in the context of libvirt, where most functions return zero on success and a negative int on failure, but it's also somewhat pointless because unless there's been a failure the returned pointer will be the same one passed in by the user, thus offering no additional value. Change the functions so that they return an int instead. Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
@@ -270,7 +270,7 @@ int virNetDevTapCreate(char **ifname,
|
||||
ifr.ifr_flags |= IFF_VNET_HDR;
|
||||
# endif
|
||||
|
||||
if (virStrcpyStatic(ifr.ifr_name, *ifname) == NULL) {
|
||||
if (virStrcpyStatic(ifr.ifr_name, *ifname) < 0) {
|
||||
virReportSystemError(ERANGE,
|
||||
_("Network interface name '%s' is too long"),
|
||||
*ifname);
|
||||
@@ -336,7 +336,7 @@ int virNetDevTapDelete(const char *ifname,
|
||||
memset(&try, 0, sizeof(struct ifreq));
|
||||
try.ifr_flags = IFF_TAP|IFF_NO_PI;
|
||||
|
||||
if (virStrcpyStatic(try.ifr_name, ifname) == NULL) {
|
||||
if (virStrcpyStatic(try.ifr_name, ifname) < 0) {
|
||||
virReportSystemError(ERANGE,
|
||||
_("Network interface name '%s' is too long"),
|
||||
ifname);
|
||||
|
||||
Reference in New Issue
Block a user