unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch-show: use correct format specifier for ssize_t
@ 2021-01-24 16:07 Đoàn Trần Công Danh
  2021-02-01 15:51 ` David Bremner
  2021-02-05 14:17 ` David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: Đoàn Trần Công Danh @ 2021-01-24 16:07 UTC (permalink / raw)
  To: notmuch; +Cc: Đoàn Trần Công Danh

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---

 I found this after inspecting one of my build today.
 I'm not sure what is acceptable action.
 I think using %zd is the right move.
 But I'm not sure if you prefer to case ssize to long int.

 notmuch-show.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index dd836add..c0498c66 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -909,7 +909,7 @@ format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),
 	    }
 
 	    if (ssize > 0 && fwrite (buf, ssize, 1, stdout) != 1) {
-		fprintf (stderr, "Error: Write %ld chars to stdout failed\n", ssize);
+		fprintf (stderr, "Error: Write %zd chars to stdout failed\n", ssize);
 		goto DONE;
 	    }
 	}
-- 
2.30.0\r

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] notmuch-show: use correct format specifier for ssize_t
  2021-01-24 16:07 [PATCH] notmuch-show: use correct format specifier for ssize_t Đoàn Trần Công Danh
@ 2021-02-01 15:51 ` David Bremner
  2021-02-02 17:52   ` Tomi Ollila
  2021-02-05 14:17 ` David Bremner
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2021-02-01 15:51 UTC (permalink / raw)
  To: Đoàn Trần Công Danh, notmuch
  Cc: Đoàn Trần Công Danh

Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:

> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> ---
>
>  I found this after inspecting one of my build today.
>  I'm not sure what is acceptable action.
>  I think using %zd is the right move.
>  But I'm not sure if you prefer to case ssize to long int.
>

If I understand correctly %zd is glibc specific? Is there a more portable way
to do this? Maybe that's what you meant by the cast.\r

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] notmuch-show: use correct format specifier for ssize_t
  2021-02-01 15:51 ` David Bremner
@ 2021-02-02 17:52   ` Tomi Ollila
  2021-02-05 15:20     ` Đoàn Trần Công Danh
  0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2021-02-02 17:52 UTC (permalink / raw)
  To: David Bremner, Đoàn Trần Công Danh, notmuch
  Cc: Đoàn Trần Công Danh

On Mon, Feb 01 2021, David Bremner wrote:

> Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:
>
>> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
>> ---
>>
>>  I found this after inspecting one of my build today.
>>  I'm not sure what is acceptable action.
>>  I think using %zd is the right move.
>>  But I'm not sure if you prefer to case ssize to long int.
>>
>
> If I understand correctly %zd is glibc specific? Is there a more portable way
> to do this? Maybe that's what you meant by the cast.

printf(3) is not too clear about that, In one place I understand
%z is "SUSv3" compatible (what that says is something vague, perhaps just
post C99), and in one place it says glibc 2.1 adds support for 'z' (but
perhaps since it is in standard already) 

Anyway, based on that I'd say %zd is standard compliant enough.

Tomi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] notmuch-show: use correct format specifier for ssize_t
  2021-01-24 16:07 [PATCH] notmuch-show: use correct format specifier for ssize_t Đoàn Trần Công Danh
  2021-02-01 15:51 ` David Bremner
@ 2021-02-05 14:17 ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2021-02-05 14:17 UTC (permalink / raw)
  To: Đoàn Trần Công Danh, notmuch
  Cc: Đoàn Trần Công Danh

Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:

> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>

applied to master

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] notmuch-show: use correct format specifier for ssize_t
  2021-02-02 17:52   ` Tomi Ollila
@ 2021-02-05 15:20     ` Đoàn Trần Công Danh
  0 siblings, 0 replies; 5+ messages in thread
From: Đoàn Trần Công Danh @ 2021-02-05 15:20 UTC (permalink / raw)
  To: Tomi Ollila; +Cc: notmuch

On 2021-02-02 19:52:20+0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> On Mon, Feb 01 2021, David Bremner wrote:
> 
> > Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:
> >
> >> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> >> ---
> >>
> >>  I found this after inspecting one of my build today.
> >>  I'm not sure what is acceptable action.
> >>  I think using %zd is the right move.
> >>  But I'm not sure if you prefer to case ssize to long int.
> >>
> >
> > If I understand correctly %zd is glibc specific? Is there a more portable way
> > to do this? Maybe that's what you meant by the cast.
> 
> printf(3) is not too clear about that, In one place I understand
> %z is "SUSv3" compatible (what that says is something vague, perhaps just
> post C99), and in one place it says glibc 2.1 adds support for 'z' (but
> perhaps since it is in standard already) 

Sorry for my late reply.
Yes %z is standard compliant, it's available from at least C99.
POSIX talks about it somewhere around that period
https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html

-- 
Danh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-05 15:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-24 16:07 [PATCH] notmuch-show: use correct format specifier for ssize_t Đoàn Trần Công Danh
2021-02-01 15:51 ` David Bremner
2021-02-02 17:52   ` Tomi Ollila
2021-02-05 15:20     ` Đoàn Trần Công Danh
2021-02-05 14:17 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).