]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli: Shrink .data segment by 43264 bytes
authorVolker Lendecke <vl@samba.org>
Tue, 28 Feb 2023 19:53:59 +0000 (20:53 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 9 Mar 2023 18:10:33 +0000 (18:10 +0000)
A case statement only references const strings, pointers in an array
need to be relocated at exec() time.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/util/doserr.c
source4/scripting/bin/gen_werror.py

index 28f709e073954f6be2173cd6073e447ca80758ed..b9553dfac5e7fb6a1a137393ab97c6cc08d0c1c4 100644 (file)
@@ -32,8 +32,6 @@ struct werror_str_struct {
         const char *friendly_errstr;
 };
 
-#include "werror_gen.c"
-
 static const struct werror_code_struct special_errs[] =
 {
        { "WERR_DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD", WERR_DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD },
@@ -108,11 +106,10 @@ const char *win_errstr(WERROR werror)
 
        idx = 0;
 
-       while (dos_errs[idx].dos_errstr != NULL) {
-               if (W_ERROR_V(dos_errs[idx].werror) ==
-                    W_ERROR_V(werror))
-                        return dos_errs[idx].dos_errstr;
-               idx++;
+       switch W_ERROR_V(werror) {
+#include "werror_gen.c"
+       default:
+               break;
        }
 
        slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror));
index a6256f158b0273b484d3e8699fca15b2ceaa193b..fd552d1ecd90c5bf0e7f10d42ae2d869dca642e5 100755 (executable)
@@ -37,19 +37,17 @@ def generateHeaderFile(out_file, errors):
     out_file.write("\n#endif /* _WERR_GEN_H */\n")
 
 def generateSourceFile(out_file, errors):
-    out_file.write("#include \"werror.h\"\n")
-
     out_file.write("/*\n")
     out_file.write(" * Names for errors generated from\n")
     out_file.write(" * [MS-ERREF] https://msdn.microsoft.com/en-us/library/cc231199.aspx\n")
     out_file.write(" */\n")
 
-    out_file.write("static const struct werror_code_struct dos_errs[] = \n")
-    out_file.write("{\n")
     for err in errors:
-        out_file.write("\t{ \"%s\", %s },\n" % (err.err_define, err.err_define))
-    out_file.write("{ 0, W_ERROR(0) }\n")
-    out_file.write("};\n")
+        if (err.err_define == 'WERR_NERR_SUCCESS'):
+            continue
+        out_file.write(f'\t case {hex(err.err_code)}:\n')
+        out_file.write(f'\t\treturn \"{err.err_define}\";\n')
+        out_file.write(f'\t\tbreak;\n')
 
 def generateFriendlySourceFile(out_file, errors):
     out_file.write("/*\n")