Mercurial > vim
comparison src/channel.c @ 13608:2a2b668cf24c v8.0.1676
patch 8.0.1676: no compiler warning for wrong printf format
commit https://github.com/vim/vim/commit/4ac2e8d8e60dcc7dbff662e177b86ccfbda7cd9e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 8 12:38:26 2018 +0200
patch 8.0.1676: no compiler warning for wrong printf format
Problem: No compiler warning for wrong printf format.
Solution: Add a printf attribute for gcc. Fix reported problems. (Dominique
Pelle, closes #2789)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 08 Apr 2018 12:45:07 +0200 |
parents | 8723e4496dd1 |
children | ea4f2a8040b4 |
comparison
equal
deleted
inserted
replaced
13607:2e79e5e6ce15 | 13608:2a2b668cf24c |
---|---|
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 static int did_log_msg = TRUE; | 159 static int did_log_msg = TRUE; |
160 | 160 |
161 #ifndef PROTO /* prototype is in vim.h */ | |
161 void | 162 void |
162 ch_log(channel_T *ch, const char *fmt, ...) | 163 ch_log(channel_T *ch, const char *fmt, ...) |
163 { | 164 { |
164 if (log_fd != NULL) | 165 if (log_fd != NULL) |
165 { | 166 { |
172 fputc('\n', log_fd); | 173 fputc('\n', log_fd); |
173 fflush(log_fd); | 174 fflush(log_fd); |
174 did_log_msg = TRUE; | 175 did_log_msg = TRUE; |
175 } | 176 } |
176 } | 177 } |
178 #endif | |
179 | |
180 static void | |
181 ch_error(channel_T *ch, const char *fmt, ...) | |
182 #ifdef __GNUC__ | |
183 __attribute__((format(printf, 2, 3))) | |
184 #endif | |
185 ; | |
177 | 186 |
178 static void | 187 static void |
179 ch_error(channel_T *ch, const char *fmt, ...) | 188 ch_error(channel_T *ch, const char *fmt, ...) |
180 { | 189 { |
181 if (log_fd != NULL) | 190 if (log_fd != NULL) |
1440 | 1449 |
1441 /* Close the pipe/socket, so that the other side gets EOF. */ | 1450 /* Close the pipe/socket, so that the other side gets EOF. */ |
1442 ch_close_part(channel, PART_IN); | 1451 ch_close_part(channel, PART_IN); |
1443 } | 1452 } |
1444 else | 1453 else |
1445 ch_log(channel, "Still %d more lines to write", | 1454 ch_log(channel, "Still %ld more lines to write", |
1446 buf->b_ml.ml_line_count - lnum + 1); | 1455 (long)(buf->b_ml.ml_line_count - lnum + 1)); |
1447 } | 1456 } |
1448 | 1457 |
1449 /* | 1458 /* |
1450 * Handle buffer "buf" being freed, remove it from any channels. | 1459 * Handle buffer "buf" being freed, remove it from any channels. |
1451 */ | 1460 */ |
1534 if (written == 1) | 1543 if (written == 1) |
1535 ch_log(channel, "written line %d to channel", (int)lnum - 1); | 1544 ch_log(channel, "written line %d to channel", (int)lnum - 1); |
1536 else if (written > 1) | 1545 else if (written > 1) |
1537 ch_log(channel, "written %d lines to channel", written); | 1546 ch_log(channel, "written %d lines to channel", written); |
1538 if (lnum < buf->b_ml.ml_line_count) | 1547 if (lnum < buf->b_ml.ml_line_count) |
1539 ch_log(channel, "Still %d more lines to write", | 1548 ch_log(channel, "Still %ld more lines to write", |
1540 buf->b_ml.ml_line_count - lnum); | 1549 (long)(buf->b_ml.ml_line_count - lnum)); |
1541 | 1550 |
1542 in_part->ch_buf_bot = lnum; | 1551 in_part->ch_buf_bot = lnum; |
1543 } | 1552 } |
1544 } | 1553 } |
1545 if (!found_one) | 1554 if (!found_one) |
2079 || tv->vval.v_number == 0 | 2088 || tv->vval.v_number == 0 |
2080 || tv->vval.v_number != channel->ch_part[part].ch_block_id)))) | 2089 || tv->vval.v_number != channel->ch_part[part].ch_block_id)))) |
2081 { | 2090 { |
2082 *rettv = item->jq_value; | 2091 *rettv = item->jq_value; |
2083 if (tv->v_type == VAR_NUMBER) | 2092 if (tv->v_type == VAR_NUMBER) |
2084 ch_log(channel, "Getting JSON message %d", tv->vval.v_number); | 2093 ch_log(channel, "Getting JSON message %ld", |
2094 (long)tv->vval.v_number); | |
2085 remove_json_node(head, item); | 2095 remove_json_node(head, item); |
2086 return OK; | 2096 return OK; |
2087 } | 2097 } |
2088 item = item->jq_next; | 2098 item = item->jq_next; |
2089 } | 2099 } |