Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
>But you didn't write any tests before this diff, and as a result you broke >chmod. Retrofitting test suite requires some effort and didn't do that now because... My apologies for two things: 1. I do, forgot to put question mark. My intention was to _ask_ for that code: "WTF this?" 2. I put th

Re: chmod.c undefined behavior

2014-09-24 Thread Henri Kemppainen
> That is good convention. But while the function is so big, it is harder > to read. > > >You then also need to shovel > >data back and forth between these functions. > > Not necessarily. When the program is this tiny, single file source, > it may not so bad thing to use global scope for that share

Re: Speeding up openbsd on amd64 MP - patch 2/2

2014-09-24 Thread Christian Weisgerber
On 2014-09-14, Stefan Fritsch wrote: > Optimize pmap on amd64 > > based on a patch for i386 by Art from 2008 that removes the APTE stuff. > Some additional bits were taken from a patch by Art for amd64 from 2005. I put this on the amd64 ports machines (2 x Xeon E5-2637 for a total of hw.ncpu=8

Re: chmod.c undefined behavior

2014-09-24 Thread Theo de Raadt
>I have about million lines of build and other errors under review >where I have found anomalies. Some of them seems to be errors >in OpenBSD, most of them are errors in code. Yet somehow out of those million you decided to send in a patch which introduced a bug. I believe I know your type.

Re: chmod.c undefined behavior

2014-09-24 Thread Theo de Raadt
>>That main function is good, standard style. > >Unnecessary goto, variables defined far away from where they are used, >monster function, variables are not commented what they do, not all >functions are commented what they do.. > >To me, it looks like that there is no intention to optimize readabi

Re: chmod.c undefined behavior

2014-09-24 Thread Eugene Yunak
Can you two please continue this spam off-list, or at least in misc? On 24 September 2014 23:52, Matti Karnaattu wrote: > > You were probably trained in the Object-oriented (and likely a bit of > post-OO) tradition. Most likely you learned > > Java, and then possibly either C# or Ruby. > > I st

Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
> You were probably trained in the Object-oriented (and likely a bit of > post-OO) tradition. Most likely you learned > Java, and then possibly either C# or Ruby. I started C-64 Basic, then I learned assembler, then C. After C, I have learned bunch object oriented and functional languages. Late

Re: [Patch]openrcs: atoi to strtonum

2014-09-24 Thread Otto Moerbeek
On Wed, Sep 24, 2014 at 05:13:47PM +0200, Fritjof Bornebusch wrote: > Hi, > > I changed atoi to strtonum in order to avoid overflows. One concern: atoi() does not mind trailing stuff, while strtonum() does. Did you verify that the strings are just numbers in all cases? -Otto > > fritj

Re: chmod.c undefined behavior

2014-09-24 Thread Ingo Schwarze
Hi Matti, Matti Karnaattu wrote on Wed, Sep 24, 2014 at 09:44:52PM +0300: > And that reason, why not select single component to be as a reference? It's not really needed. If you want good examples, just look for new programs or library functions recently written from scratch by experienced deve

Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
> If you try to write down a long list, that is not ideal. > You will waste a lot of time, and others may not even > find the time to read the whole list. True. As OpenBSD aims for POSIX compatibility, I'm thinking about document of missing features, known anomalies, known bugs and reasons for tho

Re: chmod.c undefined behavior

2014-09-24 Thread Ingo Schwarze
Hi Matti, Matti Karnaattu wrote on Wed, Sep 24, 2014 at 09:14:45PM +0300: > Thanks for your patience. I feel like I'm querying preferred > coding style by this way. That's not the *goal*, but it's an unavoidable side effect, and the more it succeeds, the easier everuthing gets for both sides. [

Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
> It's not as easy as that. Not only is the code constantly improved, > our standards which idioms are considered good and which are considered > dangerous constantly evolve as well, slowly turning new, high quality > code into old code of lower quality - even if the code remains > completely unch

Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
>Bringing that up is the only way to find out what OpenBSD developers >do consider poor quality, what they don't, and what is merely >considered a matter of style here Thanks for your patience. I feel like I'm querying preferred coding style by this way. I also think that better way to do that is

Re: chmod.c undefined behavior

2014-09-24 Thread Ingo Schwarze
Hi Matti, Matti Karnaattu wrote on Wed, Sep 24, 2014 at 08:14:27PM +0300: > I think that it is not defined enough unambiguously, how ideal code > looks like. It reduces motivation to improve code better, if it is not > defined, what is better. > > style(9) is good, but it would be better if ther

Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
>Or the most straightforward and obvious way to break out of a switch >in a loop. True. It is also good way to model exeptions. I take my word back, this may be most elegant way to exit that loop in this case. >Variables def

Re: chmod.c undefined behavior

2014-09-24 Thread Ingo Schwarze
Hi Miod, Miod Vallat wrote on Wed, Sep 24, 2014 at 04:27:26PM +0200: > There is only one goto in chmod.c. If you consider it unnecessary, I'd > advise you to read the code again, and pay attention to the comment > explaining that particular chunk. Heh. "Read the code" is almost always good advi

Re: bgpctl: enlarge columns for 4-byte ASN display

2014-09-24 Thread Gregor Best
On Sun, Jul 27, 2014 at 10:06:12PM +0100, Stuart Henderson wrote: > [...] > Nice, I like that a lot. What do you think Claudio? > [...] Ping. Are there remaining issues with the patch? -- Gregor Best

[Patch]openrcs: atoi to strtonum

2014-09-24 Thread Fritjof Bornebusch
Hi, I changed atoi to strtonum in order to avoid overflows. fritjof Index: rcstime.c === RCS file: /cvs/src/usr.bin/rcs/rcstime.c,v retrieving revision 1.4 diff -u -p -r1.4 rcstime.c --- rcstime.c 29 Apr 2014 07:44:19 -

Re: chmod.c undefined behavior

2014-09-24 Thread Henri Kemppainen
> Unnecessary goto Or the most straightforward and obvious way to break out of a switch in a loop. > variables defined far away from where they are used, Variables defined predictably at the start of the function, as the convention is in BSD code. Yes, they can be a little far if the function i

Re: chmod.c undefined behavior

2014-09-24 Thread Miod Vallat
That main function is good, standard style. Unnecessary goto, There is only one goto in chmod.c. If you consider it unnecessary, I'd advise you to read the code again, and pay attention to the comment explaining that particular chunk. (Hint: you can't break from more than one control structure

Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
>That main function is good, standard style. Unnecessary goto, variables defined far away from where they are used, monster function, variables are not commented what they do, not all functions are commented what they do.. To me, it looks like that there is no intention to optimize readability an

Re: chmod.c undefined behavior

2014-09-24 Thread David Carlier
You make the point indeed I had "overreacted", just tried to participate :-) >I mght be wrong, but why not just initialize to NULL? I am watching this thread to spot people who should never be OpenBSD developers.. Eheh you re probably right. On 24 September 2014 13:22, Ingo Schwarze wrote: >

Re: chmod.c undefined behavior

2014-09-24 Thread Theo de Raadt
>I mght be wrong, but why not just initialize to NULL? I am watching this thread to spot people who should never be OpenBSD developers...

Re: chmod.c undefined behavior

2014-09-24 Thread Ingo Schwarze
Hi David, David Carlier wrote on Wed, Sep 24, 2014 at 10:19:57AM +0100: > On 24 September 2014 10:10, Matti Karnaattu wrote: >> I noticed that chmod.c have uninitialized variable char *ep >> that was used. This diff clarify what I mean. > I might be wrong, You are. > but why not just initial

Re: chmod.c undefined behavior

2014-09-24 Thread Ingo Schwarze
Hi Matti, Matti Karnaattu wrote on Wed, Sep 24, 2014 at 12:55:14PM +0300: > I got confused for that monster main function. > That is definitely overly complex I strongly disagree. That main function is good, standard style. Actually, it's good enough to be shown off as an example. A small utili

Re: chmod.c undefined behavior

2014-09-24 Thread David Carlier
I mght be wrong, but why not just initialize to NULL? On 24 September 2014 10:10, Matti Karnaattu wrote: > I noticed that chmod.c have uninitialized variable char *ep that was > used. This diff clarify what I mean. > > > Index: chmod.c > =

Re: chmod.c undefined behavior

2014-09-24 Thread Otto Moerbeek
On Wed, Sep 24, 2014 at 12:10:47PM +0300, Matti Karnaattu wrote: > I noticed that chmod.c have uninitialized variable char *ep that was > used. This diff clarify what I mean. &ep is passed to strtoul(), wonder what it does with it... -Otto > > > Index: chmod.c > =

Re: chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
Now I see it, in the last sentence. I was wrong, it was actually used. I got confused for that monster main function. That is definitely overly complex and that *ep looked like a forgotten. Hmm.. I counted cyclomatic complexity.. and that is 65 in main function :|

Re: chmod.c undefined behavior

2014-09-24 Thread Ingo Schwarze
Hi Matti, Matti Karnaattu wrote on Wed, Sep 24, 2014 at 12:10:47PM +0300: > I noticed that chmod.c have uninitialized variable char *ep > that was used. Your analysis is wrong. The variable ep is explicitly initialized by strtoul() before being used in main(). > This diff clarify what I mean.

Re: chmod.c undefined behavior

2014-09-24 Thread Henri Kemppainen
> I noticed that chmod.c have uninitialized variable char *ep that was > used. This diff clarify what I mean. It might be a good idea to take a careful look at the man page of strtoul(3). Pay attention to what it does with errno and endptr. Also, take a look at the example.

chmod.c undefined behavior

2014-09-24 Thread Matti Karnaattu
I noticed that chmod.c have uninitialized variable char *ep that was used. This diff clarify what I mean. Index: chmod.c === RCS file: /OpenBSD/src/bin/chmod/chmod.c,v retrieving revision 1.30 diff -u -p -u -p -r1.30 chmod.c --- chm