Get rid of err function codes.

Running make_errors.go every time a function is renamed is incredibly
tedious. Plus we keep getting them wrong.

Instead, sample __func__ (__FUNCTION__ in MSVC) in the OPENSSL_PUT_ERROR macro
and store it alongside file and line number. This doesn't change the format of
ERR_print_errors, however ERR_error_string_n now uses the placeholder
"OPENSSL_internal" rather than an actual function name since that only takes
the uint32_t packed error code as input.

This updates err scripts to not emit the function string table. The
OPENSSL_PUT_ERROR invocations, for now, still include the extra
parameter. That will be removed in a follow-up.

BUG=468039

Change-Id: Iaa2ef56991fb58892fa8a1283b3b8b995fbb308d
Reviewed-on: https://boringssl-review.googlesource.com/5275
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/err/err_data_generate.go b/crypto/err/err_data_generate.go
index a5b4cb5..8b1c02d 100644
--- a/crypto/err/err_data_generate.go
+++ b/crypto/err/err_data_generate.go
@@ -69,7 +69,7 @@
 	// entries is an array of keys and offsets into |stringData|. The
 	// offsets are in the bottom 15 bits of each uint32 and the key is the
 	// top 17 bits.
-	entries         []uint32
+	entries []uint32
 	// internedStrings contains the same strings as are in |stringData|,
 	// but allows for easy deduplication. It maps a string to its offset in
 	// |stringData|.
@@ -146,7 +146,7 @@
 		fmt.Fprintf(out, "    0x%x,\n", v)
 	}
 	out.WriteString("};\n\n")
-	out.WriteString("const size_t " + values + "Len = sizeof(" + values + ") / sizeof(" + values + "[0]);\n\n");
+	out.WriteString("const size_t " + values + "Len = sizeof(" + values + ") / sizeof(" + values + "[0]);\n\n")
 
 	stringData := "kOpenSSL" + name + "StringData"
 	out.WriteString("const char " + stringData + "[] =\n    \"")
@@ -161,8 +161,8 @@
 }
 
 type errorData struct {
-	functions, reasons *stringList
-	libraryMap         map[string]uint32
+	reasons    *stringList
+	libraryMap map[string]uint32
 }
 
 func (e *errorData) readErrorDataFile(filename string) error {
@@ -184,8 +184,8 @@
 			continue
 		}
 		parts := bytes.Split(line, comma)
-		if len(parts) != 4 {
-			return fmt.Errorf("bad line %d in %s: found %d values but want 4", lineNo, filename, len(parts))
+		if len(parts) != 3 {
+			return fmt.Errorf("bad line %d in %s: found %d values but want 3", lineNo, filename, len(parts))
 		}
 		libNum, ok := e.libraryMap[string(parts[0])]
 		if !ok {
@@ -194,26 +194,18 @@
 		if libNum >= 64 {
 			return fmt.Errorf("bad line %d in %s: library value too large", lineNo, filename)
 		}
-		key, err := strconv.ParseUint(string(parts[2]), 10 /* base */, 32 /* bit size */)
+		key, err := strconv.ParseUint(string(parts[1]), 10 /* base */, 32 /* bit size */)
 		if err != nil {
 			return fmt.Errorf("bad line %d in %s: %s", lineNo, filename, err)
 		}
 		if key >= 2048 {
 			return fmt.Errorf("bad line %d in %s: key too large", lineNo, filename)
 		}
-		value := string(parts[3])
+		value := string(parts[2])
 
 		listKey := libNum<<26 | uint32(key)<<15
 
-		switch string(parts[1]) {
-		case "function":
-			err = e.functions.Add(listKey, value)
-		case "reason":
-			err = e.reasons.Add(listKey, value)
-		default:
-			return fmt.Errorf("bad line %d in %s: bad value type", lineNo, filename)
-		}
-
+		err = e.reasons.Add(listKey, value)
 		if err != nil {
 			return err
 		}
@@ -224,7 +216,6 @@
 
 func main() {
 	e := &errorData{
-		functions:  newStringList(),
 		reasons:    newStringList(),
 		libraryMap: make(map[string]uint32),
 	}
@@ -279,9 +270,8 @@
 	for i, name := range libraryNames {
 		fmt.Fprintf(out, "OPENSSL_COMPILE_ASSERT(ERR_LIB_%s == %d, library_values_changed_%d);\n", name, i+1, i+1)
 	}
-	fmt.Fprintf(out, "OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == %d, library_values_changed_num);\n", len(libraryNames) + 1)
+	fmt.Fprintf(out, "OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == %d, library_values_changed_num);\n", len(libraryNames)+1)
 	out.WriteString("\n")
 
-	e.functions.WriteTo(out, "Function")
 	e.reasons.WriteTo(out, "Reason")
 }