From 6e2cb1bddbc8e24428ba7ce86f0b66c85f6738e5 Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Fri, 25 Apr 2014 11:47:25 +0200 Subject: Use portable format specifiers: Case %ld - plain - sscanf. Fix uses of plain "%ld" within sscanf(): - Replace "%ld" with "%" SCNd64. - Create (int64_t) local variable and sscanf into that. - Safely downcast into previous type (introduce assertion, to be removed when variable type refactored). --- src/mark.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mark.c b/src/mark.c index eb066535f5..d5dd868167 100644 --- a/src/mark.c +++ b/src/mark.c @@ -1493,9 +1493,12 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags while (!(eof = viminfo_readline(virp)) && line[0] == TAB) { if (load_marks) { if (line[1] != NUL) { + int64_t lnum_64; unsigned u; - - sscanf((char *)line + 2, "%ld %u", &pos.lnum, &u); + sscanf((char *)line + 2, "%" SCNd64 "%u", &lnum_64, &u); + // safely downcast to linenr_T (long); remove when linenr_T refactored + assert(lnum_64 <= LONG_MAX); + pos.lnum = (linenr_T)lnum_64; pos.col = u; switch (line[1]) { case '"': curbuf->b_last_cursor = pos; break; -- cgit