tenox7 / ttyplot

a realtime plotting utility for terminal/console with data input from stdin
Apache License 2.0
961 stars 43 forks source link

error: format not a string literal and no format arguments #80

Closed kseistrup closed 1 year ago

kseistrup commented 1 year ago

Commit 71d4aa7120f540b453f5c4d0ba7c464df74c4137 will not compile with -Werror=format-security because the error string does not have any formatting and no format arguments are given to mvprintw():

gcc -march=x86-64 -mtune=native -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -flto=auto -Wall -Wextra -D_FORTIFY_SOURCE=2 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto  ttyplot.c  -lcurses -ltinfo -o ttyplot
ttyplot.c: In function ‘main’:
ttyplot.c:318:13: error: format not a string literal and no format arguments [-Werror=format-security]
  318 |             mvprintw(height/2, (width/2)-(strlen(errstr)/2), errstr);
      |             ^~~~~~~~
cc1: some warnings being treated as errors
make: *** [<builtin>: ttyplot] Error 1

https://github.com/tenox7/ttyplot/blob/master/ttyplot.c#L318

Using the following will solve the problem:

            mvprintw(height/2, (width/2)-(strlen(errstr)/2), "%s", errstr);
tenox7 commented 1 year ago

dang, thank you!

tenox7 commented 1 year ago

I think mvaddstr may be better

tenox7 commented 1 year ago

ok fixed now... I hope?

tenox7 commented 1 year ago

feel free to reopen if this is an issue

kseistrup commented 1 year ago

ok fixed now... I hope?

Thanks, it compiles without problems now. 👍

tenox7 commented 1 year ago

cool thanks for reporting!