Logically, the final branch of the if should be qualified with a check
for the emptiness of FreeBSDDist.  This is awkward in the current
structure, since we really want to do the distpath lookup only if
needed.  (This is not very important right now, but we are about to
add another case which will do a more-likely-to-bomb-out and
more-likely-to-block-on-the-db lookup.)  So refactor into `return'
style.  This lets us introduce local variables in each branch.

Now gate the final branch appropriately.  The overall result is that
if no useful FreeBSD build is found, we simply do not set the
freebsd_* runvars, rather than setting them to wrong values (eg,
`freebsd_distpath=/i386'.

Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com>
CC: Roger Pau Monné <roger....@citrix.com>
---
 mfi-common | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/mfi-common b/mfi-common
index cef28ad..17b1b50 100644
--- a/mfi-common
+++ b/mfi-common
@@ -133,14 +133,19 @@ set_freebsd_runvars () {
     local envvar="FREEBSD_${arch^^}_BUILDJOB"
     if [ -n "${!envvar}" ]; then
         freebsd_runvars="freebsdbuildjob=${!envvar}"
-    elif [ -n "$FREEBSD_DIST" ] && [ -n "$FREEBSD_VERSION" ]; then
+        return
+    fi
+    if [ -n "$FREEBSD_DIST" ] && [ -n "$FREEBSD_VERSION" ]; then
         freebsd_runvars="freebsd_distpath=$FREEBSD_DIST/$arch \
                          freebsd_version=$FREEBSD_VERSION"
-    else
-        local distpath=`getconfig "FreeBSDDist"`
+        return
+    fi
+    local distpath=`getconfig "FreeBSDDist"`
+    if [ -n "$distpath" ]; then
         local version=`getconfig "FreeBSDVersion"`
         freebsd_runvars="freebsd_distpath=$distpath/$arch \
                          freebsd_version=$version"
+        return
     fi
 }
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to