Skip to content

Commit

Permalink
Fix Ubuntu warning for asprintf in s-golay filter
Browse files Browse the repository at this point in the history
Briscoe reported a warning about not using the return
value from a asprintf call on Ubuntu:

filter_sgolay.cpp:143:17: warning: ignoring return value
of ‘int asprintf(char**, const char*, ...)’ declared with attribute
‘warn_unused_result’ [-Wunused-result]
 143 |         asprintf(&buffer, "cannot build matrix with %lu rows and %lu columns\n",
  • Loading branch information
keithvetter committed Oct 30, 2024
1 parent 5898152 commit ba6c430
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libkoviz/filter_sgolay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,15 @@ float_mat::float_mat(const size_t rows,const size_t cols,const double defval)
}
if ((rows < 1) || (cols < 1)) {
char* buffer;
asprintf(&buffer, "cannot build matrix with %lu rows and %lu columns\n",
rows, cols);
sgs_error(buffer);
free(buffer);
int ret = asprintf(&buffer,
"cannot build matrix with %lu rows and %lu columns\n",
rows, cols);
if ( ret > 0 ) {
sgs_error(buffer);
free(buffer);
} else {
sgs_error("koviz [error]: S-golay filter can't allocate memory!\n");
}
}
}

Expand Down

0 comments on commit ba6c430

Please sign in to comment.