Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding C/C++ linter to CI #148

Merged
merged 23 commits into from
Jul 11, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/aes_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,37 @@ name: Repo Integration
on: [push]

jobs:
# ----------------------------------------------------------------------------
test_and_document:
name: Test And Generate Documentation
runs-on: ubuntu-22.04
steps:

# This step checks out a copy of your repository.
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install python3 python3-pip
python -m pip install --upgrade pip
pip install -r pip_requirements.txt

# C/C++ Linter
- name: C/C++ Linter
run: |
find . -name '*.h' -o -name '*.cpp' -o -name '*.c' | xargs cpplint

# ----------------------------------------------------------------------------

gen_release:
needs: [test_and_document]
uses: slaclab/ruckus/.github/workflows/gen_release.yml@main
with:
version: '1.0.0'
Expand Down
34 changes: 34 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#######################################################
# CPPLINT.cfg
#######################################################

# Increase the max number of characters on a given line
linelength=250

# List of filters to apply
filter=-legal/copyright

# Disable the build/header_guard check
# Note changing header guard has wrong style
# E.g. from __ROGUE_UTILITIES_FILEIO_MODULE_H__ to INCLUDE_ROGUE_UTILITIES_MODULE_H_
filter=-build/header_guard

# Disable the readability/casting check
# Because we are using C code in the kernel driver (no C++)
filter=-readability/casting

# Disable the runtime/int check
# Because linux kernel API sometimes need unsigned long types
# (e.g. include/linux/spinlock.h & typecheck(unsigned long, flags) macro)
filter=-runtime/int

# Disable the runtime/threadsafe_fn check
# Because application rate testers are known to operation in unsafe thread mode
filter=-runtime/threadsafe_fn

# Disable the build/include_subdir check
# Because headers are organized in same directory and C kernel driver code
filter=-build/include_subdir

# TODO: We need to make a decision on what number of spaces for indent
filter=-whitespace/indent
10 changes: 7 additions & 3 deletions common/app_lib/PrbsData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ bool PrbsData::processData(const void *data, uint32_t size) {
// Verify PRBS sequence
for (word = 2; word < size / (_width / 8); word++) {
expected = flfsr(expected);
if (_width == 16) got = data16[word];
else if (_width == 32) got = data32[word];
else got = 0;
if (_width == 16) {
got = data16[word];
} else if (_width == 32) {
got = data32[word];
} else {
got = 0;
}

if (expected != got) {
fprintf(stderr, "Bad value at index %i. exp=0x%x, got=0x%x\n", word, expected, got);
Expand Down
2 changes: 1 addition & 1 deletion common/app_lib/PrbsData.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ class PrbsData {
bool processData(const void *data, uint32_t size);
};

#endif // __PRBS_DATA_H__
#endif // __PRBS_DATA_H__
36 changes: 18 additions & 18 deletions common/driver/axi_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,37 +121,37 @@ void AxiVersion_Show(struct seq_file *s, struct DmaDevice *dev, struct AxiVersio
int32_t x;
bool gitDirty = true;

seq_printf(s,"---------- Firmware Axi Version -----------\n");
seq_printf(s," Firmware Version : 0x%x\n",aVer->firmwareVersion);
seq_printf(s," ScratchPad : 0x%x\n",aVer->scratchPad);
seq_printf(s," Up Time Count : %u\n",aVer->upTimeCount);

// seq_printf(s," Fd Value : 0x");
// for (x=0; x < 8; x++) seq_printf(s,"%.02x",aVer->fdValue[8-x]);
// seq_printf(s,"\n");
seq_printf(s, "---------- Firmware Axi Version -----------\n");
seq_printf(s, " Firmware Version : 0x%x\n", aVer->firmwareVersion);
seq_printf(s, " ScratchPad : 0x%x\n", aVer->scratchPad);
seq_printf(s, " Up Time Count : %u\n", aVer->upTimeCount);

// seq_printf(s, " Fd Value : 0x");
// for (x=0; x < 8; x++) seq_printf(s, "%.02x", aVer->fdValue[8-x]);
// seq_printf(s, "\n");
// for (x=0; x < 64; x++)
// seq_printf(s," User Values : 0x%x\n",aVer->userValues[x]);
// seq_printf(s," Device ID : 0x%x\n",aVer->deviceId);
// seq_printf(s, " User Values : 0x%x\n", aVer->userValues[x]);
// seq_printf(s, " Device ID : 0x%x\n", aVer->deviceId);

// Git hash processing to determine if code is 'dirty'
seq_printf(s," Git Hash : ");
seq_printf(s, " Git Hash : ");
for (x=0; x < 20; x++) {
if ( aVer->gitHash[19-x] != 0 ) gitDirty = false;
}
if ( gitDirty ) {
seq_printf(s,"dirty (uncommitted code)");
seq_printf(s, "dirty (uncommitted code)");
} else {
for (x=0; x < 20; x++) seq_printf(s,"%.02x",aVer->gitHash[19-x]);
for (x=0; x < 20; x++) seq_printf(s, "%.02x", aVer->gitHash[19-x]);
}
seq_printf(s,"\n");
seq_printf(s, "\n");

// Displaying DNA value
seq_printf(s," DNA Value : 0x");
for (x=0; x < 16; x++) seq_printf(s,"%.02x",aVer->dnaValue[15-x]);
seq_printf(s,"\n");
seq_printf(s, " DNA Value : 0x");
for (x=0; x < 16; x++) seq_printf(s, "%.02x", aVer->dnaValue[15-x]);
seq_printf(s, "\n");

// Build string display
seq_printf(s," Build String : %s\n",aVer->buildString);
seq_printf(s, " Build String : %s\n", aVer->buildString);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion common/driver/axi_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ void AxiVersion_Read(struct DmaDevice *dev, void *base, struct AxiVersion *aVer)
void AxiVersion_Show(struct seq_file *s, struct DmaDevice *dev, struct AxiVersion *aVer);
void AxiVersion_SetUserReset(void *base, bool state);

#endif // __AXI__VERSION_H__
#endif // __AXI__VERSION_H__
Loading
Loading