tools, bpftool: Exit on error in function codegen
[sfrench/cifs-2.6.git] / tools / bpf / bpftool / gen.c
index ecbae47e66b82207880fdc5d265d8aa6390b59d6..7443879e87afea37122ff4914f10f982a7f3e7df 100644 (file)
@@ -200,7 +200,7 @@ out:
        return err;
 }
 
-static int codegen(const char *template, ...)
+static void codegen(const char *template, ...)
 {
        const char *src, *end;
        int skip_tabs = 0, n;
@@ -211,7 +211,7 @@ static int codegen(const char *template, ...)
        n = strlen(template);
        s = malloc(n + 1);
        if (!s)
-               return -ENOMEM;
+               exit(-1);
        src = template;
        dst = s;
 
@@ -225,7 +225,7 @@ static int codegen(const char *template, ...)
                        p_err("unrecognized character at pos %td in template '%s'",
                              src - template - 1, template);
                        free(s);
-                       return -EINVAL;
+                       exit(-1);
                }
        }
 
@@ -236,7 +236,7 @@ static int codegen(const char *template, ...)
                                p_err("not enough tabs at pos %td in template '%s'",
                                      src - template - 1, template);
                                free(s);
-                               return -EINVAL;
+                               exit(-1);
                        }
                }
                /* trim trailing whitespace */
@@ -257,7 +257,8 @@ static int codegen(const char *template, ...)
        va_end(args);
 
        free(s);
-       return n;
+       if (n)
+               exit(-1);
 }
 
 static int do_skeleton(int argc, char **argv)