Commit 9d1986f9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Simplify VIN_n_Arg() to return the directory directly.

parent 879c9b37
......@@ -782,8 +782,8 @@ main(int argc, char * const *argv)
VJ_master(JAIL_MASTER_LOW);
}
if (VIN_n_Arg(n_arg, &workdir) != 0)
ARGV_ERR("Invalid instance (-n) name: %s\n", VAS_errtxt(errno));
workdir = VIN_n_Arg(n_arg);
AN(workdir);
if (i_arg == NULL || *i_arg == '\0')
i_arg = mgt_HostName();
......
......@@ -34,5 +34,5 @@
#define VIN_H_INCLUDED
/* This function lives in both libvarnish and libvarnishapi */
int VIN_n_Arg(const char *n_arg, char **dir);
char *VIN_n_Arg(const char *n_arg);
#endif
......@@ -54,6 +54,7 @@
* binary/load-time compatible, increment MAJOR version
*
* NEXT (2021-09-15)
* VIN_n_Arg() no directly returns the directory name.
* VSB_new() and VSB_delete() removed
* VCL_STRINGLIST, vrt_magic_string_end removed
* VRT_String(), VRT_StringList(), VRT_CollectString() removed
......
......@@ -42,12 +42,11 @@
#include "vin.h"
#include "vsb.h"
int
VIN_n_Arg(const char *n_arg, char **dir)
char *
VIN_n_Arg(const char *n_arg)
{
struct vsb *vsb;
AN(dir);
char *retval;
vsb = VSB_new_auto();
AN(vsb);
......@@ -63,9 +62,7 @@ VIN_n_Arg(const char *n_arg, char **dir)
}
AZ(VSB_finish(vsb));
*dir = strdup(VSB_data(vsb));
retval = strdup(VSB_data(vsb));
VSB_destroy(&vsb);
if (*dir == NULL)
return (-1);
return (0);
return (retval);
}
......@@ -387,12 +387,12 @@ VSM_Arg(struct vsm *vd, char flag, const char *arg)
}
break;
case 'n':
if (VIN_n_Arg(arg, &p))
if (vd->wdname != NULL)
free(vd->wdname);
vd->wdname = VIN_n_Arg(arg);
if (vd->wdname == NULL)
return (vsm_diag(vd, "Invalid instance name: %s",
strerror(errno)));
AN(p);
REPLACE(vd->wdname, p);
free(p);
break;
default:
return (vsm_diag(vd, "Unknown VSM_Arg('%c')", flag));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment