Skip to content

Commit

Permalink
Merge pull request #325 from Libvisual/clang-18-fixes
Browse files Browse the repository at this point in the history
libvisual-plugins (lcdcontrol): Address Clang 18 warning `-Wvla-cxx-extension` to fix CI
  • Loading branch information
hartwork authored Nov 8, 2023
2 parents 299f497 + a0b651b commit fdc85fc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
5 changes: 4 additions & 1 deletion libvisual-plugins/plugins/actor/lcdcontrol/GenericSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ void GenericSerial::SerialClose() {
int GenericSerial::SerialPoll(unsigned char *string, int len) {
if(!connected_)
return -1;
char buff[len + 1];
char * const buff = new char[len + 1];
if(!buff)
return -1;
int ret = read(fd_, buff, len);
if( ret < 0 && errno != EAGAIN ) {
LCDError("%s: read(%s) failed: %s", device_name_.c_str(), port_.c_str(), strerror(errno));
}
for(int i = 0; i < ret; i++ ) {
string[i] = buff[i];
}
delete []buff;
return ret;
}

Expand Down
32 changes: 28 additions & 4 deletions libvisual-plugins/plugins/actor/lcdcontrol/LCDText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ void LCDText::TextBlit(int row, int col, int height,
int dr, dc; /* display row/col */
int p1, p2; /* start/end positon of changed area */
int eq; /* counter for equal contents */
char fb[LROWS * LCOLS];
char * const fb = new char[LROWS * LCOLS];

if (!fb)
return;

memset(fb, ' ', LROWS * LCOLS);
for(int r = row; r < LROWS && r < row + height; r++) {
Expand Down Expand Up @@ -207,6 +210,8 @@ void LCDText::TextBlit(int row, int col, int height,
DisplayFB + dr * DCOLS + p1, p2 - p1 + 1);
}
}

delete []fb;
}

void LCDText::CleanBuffer(unsigned char **buf) {
Expand Down Expand Up @@ -769,7 +774,11 @@ void LCDText::TransitionLeftRight() {
int direction = visitor_->GetDirection();
int col;
unsigned char *left, *right;
unsigned char layout[LROWS * LCOLS], transition[LROWS * LCOLS];
unsigned char * const layout = new unsigned char[LROWS * LCOLS];
unsigned char * const transition = new unsigned char[LROWS * LCOLS];

if (!layout || !transition)
return;

// Hide last layout's special chars if new layout has special chars.
for(int l = 0; special_chars.size() > 0 && l < LAYERS; l++) {
Expand Down Expand Up @@ -827,14 +836,21 @@ void LCDText::TransitionLeftRight() {
}
TextBlit(0, 0, LROWS, LCOLS);
}

delete []layout;
delete []transition;
}

void LCDText::TransitionUpDown() {

int direction = visitor_->GetDirection();
int row;
unsigned char *top, *bottom;
unsigned char layout[LROWS * LCOLS], transition[LROWS * LCOLS];
unsigned char * const layout = new unsigned char[LROWS * LCOLS];
unsigned char * const transition = new unsigned char[LROWS * LCOLS];

if (!layout || !transition)
return;

// Hide last layout's special chars if new layout has special chars.
for(int l = LAYERS - 1; l>=0; l--) {
Expand Down Expand Up @@ -884,6 +900,9 @@ void LCDText::TransitionUpDown() {
}
TextBlit(0, 0, LROWS, LCOLS);
}

delete []layout;
delete []transition;
}

void SaneCoords(LCDText *lcd, int *x, int *y1, int *y2) {
Expand Down Expand Up @@ -929,7 +948,10 @@ void LCDText::TransitionTentacle() {
double multiplier = 0;
double multiadd = 1.0 / LCOLS;
double rate = (LCOLS - transition_tick_) / (double)LCOLS;
unsigned char layout[LCOLS * LROWS];
unsigned char * const layout = new unsigned char[LCOLS * LROWS];

if (!layout)
return;

memset(DisplayFB, (int)' ', LCOLS * LROWS);
memset(layout, (int)' ', LCOLS * LROWS);
Expand Down Expand Up @@ -982,6 +1004,8 @@ void LCDText::TransitionTentacle() {
}
TextBlit(0, 0, LROWS, LCOLS);
}

delete []layout;
}

void LCDText::TransitionCheckerBoard() {
Expand Down

0 comments on commit fdc85fc

Please sign in to comment.