Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-15 Thread Dimitris Papastamos
See attached patch. >From f6c18450a99875647d85f633fef00e72a0c1577b Mon Sep 17 00:00:00 2001 From: sin Date: Wed, 15 Apr 2015 09:43:06 +0100 Subject: [PATCH] Fix memmove() invocation with src/dst being NULL This fixes a segmentation fault on some systems. --- st.c | 7 +-- 1 file changed, 5 i

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-15 Thread Roberto E. Vargas Caballero
> This should be reverted. Yeah, I agree. I also think we should put some comment saying that if i == 0 then it is possible to have some of the undefined cases where src == NULL || dst == NULL || src == dst. Some volunter to write the patch?

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-14 Thread Omar Sandoval
On Tue, Apr 14, 2015 at 04:39:44PM +0100, Dimitris Papastamos wrote: > On Tue, Apr 14, 2015 at 04:33:56PM +0100, Connor Lane Smith wrote: > > On 14 April 2015 at 13:50, Dimitris Papastamos wrote: > > > dst and src are required to be valid objects even if n is 0, otherwise > > > this is undefined b

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-14 Thread Dimitris Papastamos
On Tue, Apr 14, 2015 at 04:33:56PM +0100, Connor Lane Smith wrote: > On 14 April 2015 at 13:50, Dimitris Papastamos wrote: > > dst and src are required to be valid objects even if n is 0, otherwise > > this is undefined behaviour. > > I looked this up in C11. Seems to be the case: > > > 7.24.2.1

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-14 Thread Connor Lane Smith
On 14 April 2015 at 13:50, Dimitris Papastamos wrote: > dst and src are required to be valid objects even if n is 0, otherwise > this is undefined behaviour. I looked this up in C11. Seems to be the case: > 7.24.2.1.2. The memcpy function copies n characters from the object > pointed to by s2 in

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-14 Thread Dimitris Papastamos
On Tue, Apr 14, 2015 at 01:43:56PM +0200, Silvan Jegen wrote: > On Tue, Apr 14, 2015 at 12:55 PM, Gregor Best wrote: > > The cause seems to be that for bot `term.line` and `term.alt` are NULL > > at this point. While this does mean that even with a `len` parameter of > > 0, the `dst` pointer gets

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-14 Thread Silvan Jegen
On Tue, Apr 14, 2015 at 12:55 PM, Gregor Best wrote: > The cause seems to be that for bot `term.line` and `term.alt` are NULL > at this point. While this does mean that even with a `len` parameter of > 0, the `dst` pointer gets touched, I don't think it's ever right to call > either `memcpy` or `m

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-14 Thread Gregor Best
This commit seems to cause st to segfault on start on OpenBSD (-current). A similar segfault has been observed in #suckless by user mvdan, using GNU libc. The cause seems to be that for bot `term.line` and `term.alt` are NULL at this point. While this does mean that even with a `len` parameter of

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-13 Thread Roberto E. Vargas Caballero
Applied, thanks.

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-13 Thread Roberto E. Vargas Caballero
> The assembly is rather irrelevant in this case. Let's write the code > the way it is most understandable and clear. Yeah, I totally agree with you here. > I'd remove the if, memmove is equivalent to a non-op when the offset > is 0. But the problem now is to decide what is more understable. I

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-12 Thread FRIGN
On Sun, 12 Apr 2015 11:36:00 +0200 koneu wrote: > It is not a nop though, but two copy operations. Even with i=0 the > function call might be more costly than a simple je. The assembly is rather irrelevant in this case. Let's write the code the way it is most understandable and clear. I'd remove

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-12 Thread noname
On Sun, Apr 12, 2015 at 11:35:42AM +0200, Silvan Jegen wrote: > I just wonder if it really will be copying the data around into a > temporary array for no reason when i == 0 (either in glibc or in another > libc). Well, it does not really move data to temporary array, memmove just chooses the righ

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-12 Thread koneu
On April 12, 2015 10:56:40 AM CEST, non...@inventati.org wrote: >On Sun, Apr 12, 2015 at 10:41:36AM +0200, Silvan Jegen wrote: >> I was thinking about this option too but in that case you would be >> calling memmove with an identical src and dst when i == 0. The man >page >> for glibc memmove(3) do

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-12 Thread Silvan Jegen
Heyhey On Sun, Apr 12, 2015 at 08:56:40AM +, non...@inventati.org wrote: > On Sun, Apr 12, 2015 at 10:41:36AM +0200, Silvan Jegen wrote: > > I was thinking about this option too but in that case you would be > > calling memmove with an identical src and dst when i == 0. The man page > > for gl

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-12 Thread noname
On Sun, Apr 12, 2015 at 10:41:36AM +0200, Silvan Jegen wrote: > I was thinking about this option too but in that case you would be > calling memmove with an identical src and dst when i == 0. The man page > for glibc memmove(3) does not mention anything about this being a noop > so I am not sure th

Re: [dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-12 Thread Silvan Jegen
On Sun, Apr 12, 2015 at 08:29:55AM +, noname wrote: > --- > st.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/st.c b/st.c > index 109122e..f183803 100644 > --- a/st.c > +++ b/st.c > @@ -2788,10 +2788,8 @@ tresize(int col, int row) { > free(term.

[dev] [st] [PATCH 4/3] tresize: remove unnecessary if

2015-04-12 Thread noname
--- st.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/st.c b/st.c index 109122e..f183803 100644 --- a/st.c +++ b/st.c @@ -2788,10 +2788,8 @@ tresize(int col, int row) { free(term.line[i]); free(term.alt[i]); } - if(i > 0) {