Skip to content

Commit 466b920

Browse files
Copilotwysaid
andcommitted
Fix code review issues: loop conditions, indexing, shell quoting
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
1 parent 4c18534 commit 466b920

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

.github/workflows/linux-build.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ jobs:
4545
-DCCAP_BUILD_TESTS=ON
4646
4747
- name: Build
48-
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
48+
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel "$(nproc)"
4949

5050
- name: Verify GLFW examples build status
5151
working-directory: build/${{ matrix.build_type }}
5252
run: |
5353
echo "Checking built examples:"
54-
ls -la | grep -E "(glfw|example)" || echo "No GLFW examples found"
54+
if compgen -G "*glfw*" > /dev/null || compgen -G "*example*" > /dev/null; then
55+
ls -la *glfw* *example* 2>/dev/null || true
56+
else
57+
echo "No GLFW examples found"
58+
fi
5559
5660
if [ "${{ matrix.build_type }}" = "Release" ]; then
5761
echo "Release build - checking if GLFW examples were built with system GLFW:"
@@ -124,13 +128,17 @@ jobs:
124128
-DCCAP_BUILD_TESTS=ON
125129
126130
- name: Build
127-
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
131+
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel "$(nproc)"
128132

129133
- name: Verify build outputs
130134
working-directory: build/${{ matrix.build_type }}
131135
run: |
132136
echo "Checking built examples:"
133-
ls -la | grep -E "(glfw|example)" || echo "No examples found"
137+
if compgen -G "*glfw*" > /dev/null || compgen -G "*example*" > /dev/null; then
138+
ls -la *glfw* *example* 2>/dev/null || true
139+
else
140+
echo "No examples found"
141+
fi
134142
echo "✓ Build completed successfully"
135143
136144
- name: Run Unit Tests
@@ -186,12 +194,12 @@ jobs:
186194
-DCCAP_BUILD_TESTS=ON
187195
188196
- name: Build ARM64
189-
run: cmake --build build/arm64/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
197+
run: cmake --build build/arm64/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel "$(nproc)"
190198

191199
- name: Build ARM64 test target (Release only)
192200
if: matrix.build_type == 'Release'
193201
run: |
194-
cmake --build build/arm64/${{ matrix.build_type }} --config ${{ matrix.build_type }} --target ccap_convert_test --parallel $(nproc)
202+
cmake --build build/arm64/${{ matrix.build_type }} --config ${{ matrix.build_type }} --target ccap_convert_test --parallel "$(nproc)"
195203
196204
- name: Install QEMU for ARM64 test emulation (PRs and main push, Release only)
197205
if: (github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && matrix.build_type == 'Release'
@@ -222,7 +230,11 @@ jobs:
222230
working-directory: build/arm64/${{ matrix.build_type }}
223231
run: |
224232
echo "Checking built ARM64 binaries:"
225-
ls -la | grep -E "(ccap|example)" || echo "No examples found"
233+
if compgen -G "*ccap*" > /dev/null || compgen -G "*example*" > /dev/null; then
234+
ls -la *ccap* *example* 2>/dev/null || true
235+
else
236+
echo "No examples found"
237+
fi
226238
echo "Verifying ARM64 architecture:"
227239
file libccap.a | grep -q "aarch64" && echo "✓ Library is ARM64" || echo "⚠ Library architecture verification failed"
228240
if [ -f "0-print_camera" ]; then
@@ -275,7 +287,7 @@ jobs:
275287
-DCCAP_BUILD_TESTS=ON
276288
277289
- name: Build
278-
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel $(nproc)
290+
run: cmake --build build/${{ matrix.build_type }} --config ${{ matrix.build_type }} --parallel "$(nproc)"
279291

280292
- name: Run Unit Tests
281293
if: matrix.build_type == 'Release'

src/ccap_convert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void yuyvToRgb_common(const uint8_t* src, int srcStride, uint8_t* dst, int dstSt
496496

497497
for (int x = 0; x < width; x += 2) {
498498
// YUYV format: Y0 U0 Y1 V0 (4 bytes for 2 pixels)
499-
int baseIdx = (x / 2) * 4;
499+
int baseIdx = x * 2;
500500
int y0 = srcRow[baseIdx + 0]; // Y0
501501
int u = srcRow[baseIdx + 1]; // U0
502502
int y1 = srcRow[baseIdx + 2]; // Y1
@@ -552,7 +552,7 @@ void uyvyToRgb_common(const uint8_t* src, int srcStride, uint8_t* dst, int dstSt
552552

553553
for (int x = 0; x < width; x += 2) {
554554
// UYVY format: U0 Y0 V0 Y1 (4 bytes for 2 pixels)
555-
int baseIdx = (x / 2) * 4;
555+
int baseIdx = x * 2;
556556
int u = srcRow[baseIdx + 0]; // U0
557557
int y0 = srcRow[baseIdx + 1]; // Y0
558558
int v = srcRow[baseIdx + 2]; // V0

src/ccap_convert_avx2.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,7 @@ AVX2_TARGET void yuyvToRgb_avx2_imp(const uint8_t* src, int srcStride, uint8_t*
11781178
}
11791179

11801180
// Handle remaining pixels (scalar implementation)
1181-
for (; x < width; x += 2) {
1182-
if (x + 1 >= width) break; // YUYV needs to be processed in pairs
1181+
for (; x + 1 < width; x += 2) {
11831182

11841183
// YUYV format: Y0 U0 Y1 V0 (4 bytes for 2 pixels)
11851184
int baseIdx = x * 2;
@@ -1405,8 +1404,7 @@ AVX2_TARGET void uyvyToRgb_avx2_imp(const uint8_t* src, int srcStride, uint8_t*
14051404
}
14061405

14071406
// Handle remaining pixels (scalar implementation)
1408-
for (; x < width; x += 2) {
1409-
if (x + 1 >= width) break; // UYVY requires paired processing
1407+
for (; x + 1 < width; x += 2) {
14101408

14111409
// UYVY format: U0 Y0 V0 Y1 (4 bytes for 2 pixels)
14121410
int baseIdx = x * 2;

0 commit comments

Comments
 (0)