irontec / sngrep

Ncurses SIP Messages flow viewer
GNU General Public License v3.0
1.02k stars 187 forks source link

Compile warnings on MacOS 10.15 - invalid conversion specifier ')' #381

Closed miconda closed 3 years ago

miconda commented 3 years ago

When compiling latest release as well as latest git devel version on Mac OS 10.15 (Catalina), I get warnings similar to #379 but also more related to %, respectively:

curses/ui_stats.c:167:50: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 4,  3,  "Calls: %d (%.1f\%)", stats.dcalls, (float) stats.dcalls * 100 / stats.dtotal);
                                               ~~^
curses/ui_stats.c:171:59: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
        mvwprintw(ui->win, 3,  33, "COMPLETED:  %d (%.1f\%)", stats.completed, (float) stats.completed * 100 / stats.dcalls);
                                                        ~~^
curses/ui_stats.c:172:59: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
        mvwprintw(ui->win, 4,  33, "CANCELLED:  %d (%.1f\%)", stats.cancelled, (float) stats.cancelled * 100 / stats.dcalls);
                                                        ~~^
curses/ui_stats.c:173:59: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
        mvwprintw(ui->win, 5,  33, "IN CALL:    %d (%.1f\%)", stats.incall,    (float) stats.incall * 100 / stats.dcalls);
                                                        ~~^
curses/ui_stats.c:174:59: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
        mvwprintw(ui->win, 6,  33, "REJECTED:   %d (%.1f\%)", stats.rejected,  (float) stats.rejected * 100 / stats.dcalls);
                                                        ~~^
curses/ui_stats.c:175:59: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
        mvwprintw(ui->win, 7,  33, "BUSY:       %d (%.1f\%)", stats.busy,      (float) stats.busy * 100 / stats.dcalls);
                                                        ~~^
curses/ui_stats.c:176:59: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
        mvwprintw(ui->win, 8,  33, "DIVERTED:   %d (%.1f\%)", stats.diverted,  (float) stats.diverted * 100 / stats.dcalls);
                                                        ~~^
curses/ui_stats.c:177:59: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
        mvwprintw(ui->win, 9,  33, "CALL SETUP: %d (%.1f\%)", stats.setup,     (float) stats.setup * 100 / stats.dcalls);
                                                        ~~^
curses/ui_stats.c:180:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 11, 3, "INVITE:    %d (%.1f\%)", stats.invite,    (float) stats.invite * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:181:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 12, 3, "REGISTER:  %d (%.1f\%)", stats.regist,    (float) stats.regist * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:182:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 13, 3, "SUBSCRIBE: %d (%.1f\%)", stats.subscribe, (float) stats.subscribe * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:183:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 14, 3, "UPDATE:    %d (%.1f\%)", stats.update,    (float) stats.update * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:184:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 15, 3, "NOTIFY:    %d (%.1f\%)", stats.notify,    (float) stats.notify * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:185:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 16, 3, "OPTIONS:   %d (%.1f\%)", stats.options,   (float) stats.options * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:186:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 17, 3, "PUBLISH:   %d (%.1f\%)", stats.publish,   (float) stats.publish * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:187:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 18, 3, "MESSAGE:   %d (%.1f\%)", stats.message,   (float) stats.message * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:188:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 19, 3, "INFO:      %d (%.1f\%)", stats.info,      (float) stats.info * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:189:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 20, 3, "BYE:       %d (%.1f\%)", stats.bye,       (float) stats.bye * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:190:53: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 21, 3, "CANCEL:    %d (%.1f\%)", stats.cancel,    (float) stats.cancel * 100 / stats.mtotal);
                                                  ~~^
curses/ui_stats.c:192:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 11, 33, "1XX: %d (%.1f\%)", stats.r100, (float) stats.r100 * 100 / stats.mtotal);
                                             ~~^
curses/ui_stats.c:193:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 12, 33, "2XX: %d (%.1f\%)", stats.r200, (float) stats.r200 * 100 / stats.mtotal);
                                             ~~^
curses/ui_stats.c:194:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 13, 33, "3XX: %d (%.1f\%)", stats.r300, (float) stats.r300 * 100 / stats.mtotal);
                                             ~~^
curses/ui_stats.c:195:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 14, 33, "4XX: %d (%.1f\%)", stats.r400, (float) stats.r400 * 100 / stats.mtotal);
                                             ~~^
curses/ui_stats.c:196:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 15, 33, "5XX: %d (%.1f\%)", stats.r500, (float) stats.r500 * 100 / stats.mtotal);
                                             ~~^
curses/ui_stats.c:197:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 16, 33, "6XX: %d (%.1f\%)", stats.r600, (float) stats.r600 * 100 / stats.mtotal);
                                             ~~^
curses/ui_stats.c:198:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 17, 33, "7XX: %d (%.1f\%)", stats.r700, (float) stats.r700 * 100 / stats.mtotal);
                                             ~~^
curses/ui_stats.c:199:48: warning: invalid conversion specifier ')' [-Wformat-invalid-specifier]
    mvwprintw(ui->win, 18, 33, "8XX: %d (%.1f\%)", stats.r800, (float) stats.r800 * 100 / stats.mtotal);

If it is supposed to get % printed by mvwprintw(), which I understand supports same specifiers as printf(), then it should be %%, not \%. Iirc, \c is simply c when c is not a special character and then the function sees %) in the parameter.

Kaian commented 3 years ago

Hi @miconda

Above commit should replace the \% with %% in the stats windows, fixing the compilation issues.

Thanks as always for your reports!!

Regards!