diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-04-08 12:38:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-04-08 12:38:26 +0200 |
commit | 4ac2e8d8e60dcc7dbff662e177b86ccfbda7cd9e (patch) | |
tree | 03d2b5045b471034c9e9f14faa99b2740fa0f6bd /src/channel.c | |
parent | 820082914122d5bf7b6e89ff30cf364ad40a560f (diff) | |
download | vim-git-4ac2e8d8e60dcc7dbff662e177b86ccfbda7cd9e.tar.gz |
patch 8.0.1676: no compiler warning for wrong printf formatv8.0.1676
Problem: No compiler warning for wrong printf format.
Solution: Add a printf attribute for gcc. Fix reported problems. (Dominique
Pelle, closes #2789)
Diffstat (limited to 'src/channel.c')
-rw-r--r-- | src/channel.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/channel.c b/src/channel.c index 581c6f603..0f2e52b97 100644 --- a/src/channel.c +++ b/src/channel.c @@ -158,6 +158,7 @@ ch_log_lead(const char *what, channel_T *ch) static int did_log_msg = TRUE; +#ifndef PROTO /* prototype is in vim.h */ void ch_log(channel_T *ch, const char *fmt, ...) { @@ -174,6 +175,14 @@ ch_log(channel_T *ch, const char *fmt, ...) did_log_msg = TRUE; } } +#endif + + static void +ch_error(channel_T *ch, const char *fmt, ...) +#ifdef __GNUC__ +__attribute__((format(printf, 2, 3))) +#endif + ; static void ch_error(channel_T *ch, const char *fmt, ...) @@ -1442,8 +1451,8 @@ channel_write_in(channel_T *channel) ch_close_part(channel, PART_IN); } else - ch_log(channel, "Still %d more lines to write", - buf->b_ml.ml_line_count - lnum + 1); + ch_log(channel, "Still %ld more lines to write", + (long)(buf->b_ml.ml_line_count - lnum + 1)); } /* @@ -1536,8 +1545,8 @@ channel_write_new_lines(buf_T *buf) else if (written > 1) ch_log(channel, "written %d lines to channel", written); if (lnum < buf->b_ml.ml_line_count) - ch_log(channel, "Still %d more lines to write", - buf->b_ml.ml_line_count - lnum); + ch_log(channel, "Still %ld more lines to write", + (long)(buf->b_ml.ml_line_count - lnum)); in_part->ch_buf_bot = lnum; } @@ -2081,7 +2090,8 @@ channel_get_json( { *rettv = item->jq_value; if (tv->v_type == VAR_NUMBER) - ch_log(channel, "Getting JSON message %d", tv->vval.v_number); + ch_log(channel, "Getting JSON message %ld", + (long)tv->vval.v_number); remove_json_node(head, item); return OK; } |