Skip to content

Commit

Permalink
ci: Disable broken rust dry-runs (aws#4384)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart authored and jmayclin committed Jan 31, 2024
1 parent ceee18e commit 57dad87
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions enforce_not_null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import re

def find_s2n_config_new_calls(directory):
# Define the regex pattern for s2n_config_new() function call
config_new = re.compile(r'\bstruct s2n_config *(.*) = s2n_config_new\s*\(')

NULL_CHECKS = [
"RESULT_ENSURE_REF(<>)",
"POSIX_ENSURE_REF(<>)",
"EXPECT_NOT_NULL(<>)",
]
# List to store file paths with matching lines
matching_files = []

# Iterate through each file in the directory and its subdirectories
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(".c"):
file_path = os.path.join(root, file)

# Open the file and read its content
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
lines = f.readlines()

results = []
for line_number, line in enumerate(lines, start=1):
match = config_new.search(line)
if match == None:
continue
variable = match.group(1)
print(variable)
print(line.strip())
matching_files.append((file_path, line_number, line.strip()))
return matching_files

# Replace 'your_codebase_directory' with the actual path to your C codebase
codebase_directory = '.'

# Find s2n_config_new() calls in the codebase
result = find_s2n_config_new_calls(codebase_directory)

# Display the results
# for file_path, line_number, line_content in result:
# print(f"File: {file_path}:{line_number}: {line_content}")

0 comments on commit 57dad87

Please sign in to comment.