Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions android-stub/src/main/java/android/crypto/hpke/HpkeSpi.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ void engineInitRecipient(@NonNull byte[] encapsulated, @NonNull PrivateKey recip
* as a sender
* @throws GeneralSecurityException on decryption failures
*/
@NonNull
byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
@NonNull byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
throws GeneralSecurityException;

/**
Expand Down
26 changes: 26 additions & 0 deletions android/src/main/java/org/conscrypt/ConscryptStatsLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.conscrypt;

/**
* Stub class for logging statistics events.
*/
public class ConscryptStatsLog {
public static final int TLS_HANDSHAKE_REPORTED = 0;

public static void write(int code, boolean arg1, int arg2, int arg3, int arg4) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void onHandshakeFinished() {
// references to the given ConscryptEngineSocket. Our internal engine will call
// the SSLEngine-receiving methods, but our callers expect the SSLSocket-receiving
// methods to get called.
@SuppressWarnings("CustomX509TrustManager")
private static X509TrustManager getDelegatingTrustManager(final X509TrustManager delegate,
final ConscryptEngineSocket socket) {
if (delegate instanceof X509ExtendedTrustManager) {
Expand Down
79 changes: 79 additions & 0 deletions fix_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
import shutil
import subprocess
import sys
from pathlib import Path
from typing import List, FrozenSet

CLANG_FORMAT_BIN: str = "clang-format"
PROJECT_PREFIX: str = "//depot/google3/third_party/java_src/conscrypt/"
VALID_EXTENSIONS: FrozenSet[str] = frozenset({".java", ".cc", ".h", ".cpp", ".c"})

def get_g4_output() -> str:
"""Runs g4 opened and returns the stdout."""
try:
return subprocess.check_output(["g4", "opened"], text=True)
except subprocess.CalledProcessError as e:
sys.exit(f"ERROR: Failed to run 'g4 opened'.\nDetails: {e}")

def parse_files(g4_output: str, project_prefix: str, root_dir: Path) -> List[str]:
"""Parses g4 output and returns a list of absolute file paths to format."""
files_to_format: List[str] = []

for line in g4_output.splitlines():
line = line.strip()
if not line:
continue

depot_path = line.split('#')[0]

if not depot_path.endswith(tuple(VALID_EXTENSIONS)):
continue

if not depot_path.startswith(project_prefix):
continue

relative_path = depot_path[len(project_prefix):]

abs_path = root_dir / relative_path
files_to_format.append(str(abs_path))

return files_to_format

def main() -> None:
script_dir = Path(__file__).resolve().parent
config_path = script_dir / ".clang-format"

try:
if not config_path.is_file():
raise FileNotFoundError(f"Config file missing at {config_path}")
except OSError as e:
sys.exit(f"ERROR: Could not access config file.\nDetails: {e}")

if not shutil.which(CLANG_FORMAT_BIN):
sys.exit(f"ERROR: '{CLANG_FORMAT_BIN}' not found in PATH.")

print("Querying opened files...")
g4_output = get_g4_output()
files_to_format = parse_files(g4_output, PROJECT_PREFIX, script_dir)

if not files_to_format:
print(f"No source files under {PROJECT_PREFIX} are currently open.")
sys.exit(0)

print(f"Formatting {len(files_to_format)} file(s) with config: {config_path}")

cmd = [
CLANG_FORMAT_BIN,
"-i",
f"-style=file:{config_path}",
] + files_to_format

try:
subprocess.run(cmd, check=True)
print("Done.")
except subprocess.CalledProcessError as e:
sys.exit(f"ERROR: clang-format failed.\nDetails: {e}")

if __name__ == "__main__":
main()
Loading