Fix cross-module errors.
Some files in crypto/x509 were moved from crypto/asn1, so they emit errors from
another module. Fix make_errors.go to account for this: cross module errors
must use the foreign module as the first argument to OPENSSL_PUT_ERROR. Both
the function code and the error code should be declared in the foreign module.
Update make_errors.go to ignore cross-module error lines when deciding which
function tokens to emit.
Change-Id: Ic38377ddd56e22d033ef91318c30510762f6445d
Reviewed-on: https://boringssl-review.googlesource.com/3383
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/util/make_errors.go b/util/make_errors.go
index d1e5438..48d9ad4 100644
--- a/util/make_errors.go
+++ b/util/make_errors.go
@@ -366,8 +366,7 @@
}
defer file.Close()
- prefix += "_"
- reasonPrefix := prefix + "R_"
+ reasonPrefix := prefix + "_R_"
var currentFunction string
scanner := bufio.NewScanner(file)
@@ -394,8 +393,9 @@
}
}
- if strings.Contains(line, "OPENSSL_PUT_ERROR(") {
- functionToken := prefix + "F_" + currentFunction
+ // Do not include cross-module error lines.
+ if strings.Contains(line, "OPENSSL_PUT_ERROR(" + prefix + ",") {
+ functionToken := prefix + "_F_" + currentFunction
if _, ok := functions[functionToken]; !ok {
functions[functionToken] = -1
}
@@ -405,7 +405,7 @@
handleDeclareMacro(line, "_F_", "OPENSSL_DECLARE_ERROR_FUNCTION(", functions)
for len(line) > 0 {
- i := strings.Index(line, prefix)
+ i := strings.Index(line, prefix + "_")
if i == -1 {
break
}