Skip to content

Commit fdc85fc

Browse files
authored
Merge pull request #325 from Libvisual/clang-18-fixes
libvisual-plugins (lcdcontrol): Address Clang 18 warning `-Wvla-cxx-extension` to fix CI
2 parents 299f497 + a0b651b commit fdc85fc

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

libvisual-plugins/plugins/actor/lcdcontrol/GenericSerial.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,17 @@ void GenericSerial::SerialClose() {
138138
int GenericSerial::SerialPoll(unsigned char *string, int len) {
139139
if(!connected_)
140140
return -1;
141-
char buff[len + 1];
141+
char * const buff = new char[len + 1];
142+
if(!buff)
143+
return -1;
142144
int ret = read(fd_, buff, len);
143145
if( ret < 0 && errno != EAGAIN ) {
144146
LCDError("%s: read(%s) failed: %s", device_name_.c_str(), port_.c_str(), strerror(errno));
145147
}
146148
for(int i = 0; i < ret; i++ ) {
147149
string[i] = buff[i];
148150
}
151+
delete []buff;
149152
return ret;
150153
}
151154

libvisual-plugins/plugins/actor/lcdcontrol/LCDText.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ void LCDText::TextBlit(int row, int col, int height,
158158
int dr, dc; /* display row/col */
159159
int p1, p2; /* start/end positon of changed area */
160160
int eq; /* counter for equal contents */
161-
char fb[LROWS * LCOLS];
161+
char * const fb = new char[LROWS * LCOLS];
162+
163+
if (!fb)
164+
return;
162165

163166
memset(fb, ' ', LROWS * LCOLS);
164167
for(int r = row; r < LROWS && r < row + height; r++) {
@@ -207,6 +210,8 @@ void LCDText::TextBlit(int row, int col, int height,
207210
DisplayFB + dr * DCOLS + p1, p2 - p1 + 1);
208211
}
209212
}
213+
214+
delete []fb;
210215
}
211216

212217
void LCDText::CleanBuffer(unsigned char **buf) {
@@ -769,7 +774,11 @@ void LCDText::TransitionLeftRight() {
769774
int direction = visitor_->GetDirection();
770775
int col;
771776
unsigned char *left, *right;
772-
unsigned char layout[LROWS * LCOLS], transition[LROWS * LCOLS];
777+
unsigned char * const layout = new unsigned char[LROWS * LCOLS];
778+
unsigned char * const transition = new unsigned char[LROWS * LCOLS];
779+
780+
if (!layout || !transition)
781+
return;
773782

774783
// Hide last layout's special chars if new layout has special chars.
775784
for(int l = 0; special_chars.size() > 0 && l < LAYERS; l++) {
@@ -827,14 +836,21 @@ void LCDText::TransitionLeftRight() {
827836
}
828837
TextBlit(0, 0, LROWS, LCOLS);
829838
}
839+
840+
delete []layout;
841+
delete []transition;
830842
}
831843

832844
void LCDText::TransitionUpDown() {
833845

834846
int direction = visitor_->GetDirection();
835847
int row;
836848
unsigned char *top, *bottom;
837-
unsigned char layout[LROWS * LCOLS], transition[LROWS * LCOLS];
849+
unsigned char * const layout = new unsigned char[LROWS * LCOLS];
850+
unsigned char * const transition = new unsigned char[LROWS * LCOLS];
851+
852+
if (!layout || !transition)
853+
return;
838854

839855
// Hide last layout's special chars if new layout has special chars.
840856
for(int l = LAYERS - 1; l>=0; l--) {
@@ -884,6 +900,9 @@ void LCDText::TransitionUpDown() {
884900
}
885901
TextBlit(0, 0, LROWS, LCOLS);
886902
}
903+
904+
delete []layout;
905+
delete []transition;
887906
}
888907

889908
void SaneCoords(LCDText *lcd, int *x, int *y1, int *y2) {
@@ -929,7 +948,10 @@ void LCDText::TransitionTentacle() {
929948
double multiplier = 0;
930949
double multiadd = 1.0 / LCOLS;
931950
double rate = (LCOLS - transition_tick_) / (double)LCOLS;
932-
unsigned char layout[LCOLS * LROWS];
951+
unsigned char * const layout = new unsigned char[LCOLS * LROWS];
952+
953+
if (!layout)
954+
return;
933955

934956
memset(DisplayFB, (int)' ', LCOLS * LROWS);
935957
memset(layout, (int)' ', LCOLS * LROWS);
@@ -982,6 +1004,8 @@ void LCDText::TransitionTentacle() {
9821004
}
9831005
TextBlit(0, 0, LROWS, LCOLS);
9841006
}
1007+
1008+
delete []layout;
9851009
}
9861010

9871011
void LCDText::TransitionCheckerBoard() {

0 commit comments

Comments
 (0)