trace(1): resolve all level-5 LLVM warnings
[minix3.git] / minix / usr.bin / trace / error.awk
blobf6a404615e27be91f0813e6a5e6918ce0c708b69
1 # Derived from libc errlist.awk
3 BEGIN {
4 printf("/* This file is automatically generated by error.awk */\n\n");
5 printf("#include \"inc.h\"\n\n");
6 printf("static const char *const errors[] = {\n");
8 /^#define/ {
9 name = $2;
10 if (name == "ELAST")
11 next;
12 number = $3;
13 if (number == "(_SIGN")
14 number = $4;
15 if (number < 0 || number == "EAGAIN")
16 next;
17 printf("\t[%s] = \"%s\",\n", name, name);
19 END {
20 printf("};\n\n");
21 printf("const char *\nget_error_name(int err)\n{\n\n");
22 printf("\tif (err >= 0 && (unsigned int)err < __arraycount(errors) &&\n");
23 printf("\t errors[err] != NULL)\n");
24 printf("\t\treturn errors[err];\n");
25 printf("\telse\n");
26 printf("\t\treturn NULL;\n");
27 printf("}\n");