On Wed, Feb 10, 2016 at 07:02:35PM +0100, Andrea Bolognani wrote:
On Wed, 2016-02-10 at 17:19 +0100, Ján Tomko wrote:
> This function returns -1 on allocation error, there's no
> need to check the path for NULL again.
> ---
> src/util/virhook.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> @@ -276,8 +275,7 @@ virHookCall(int driver,
> if (extra == NULL)
> extra = "-";
>
> - ret = virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr);
> - if ((ret < 0) || (path == NULL)) {
> + if (virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr) < 0) {
> virReportError(VIR_ERR_INTERNAL_ERROR,
> _("Failed to build path for %s hook"),
> drvstr);
ACK.
Unrelated to your changes, I notice the return value for the second
failure is -1, but the comments for virHookCall() say
Returns: 0 if the execution succeeded, 1 if the script was not found
or invalid parameters, and -1 if script returned an error
so I wonder if it should be changed to 1 instead... The script can't
have returned an error if we haven't been able to build its path :)
How do you know? We did not even get to running it. :)
In theory, bailing out because building the script path got an OOM error
is better than quietly skipping the hook script.
In practice, if we returned 1 on OOM in virBuildPath, the next
allocation will probably also fail and we won't even try to start the
domain.
Jan