Repository navigation
Conversation
|
It says "unnecessarily use braces" for a reason. :) |
excluding in particular tabular formattings like line 1152ff, where readability of the formulas takes precedence over the 80 column rule.
7a498b7 to
19f6d1d
Compare
There was a problem hiding this comment.
Blank line after the declaration. consider indenting the expression so the cast/in part lines up with the next two lines.
There was a problem hiding this comment.
Blank line after the declaration.
Thanks for the reminder. Needs to be fixed globally.
There was a problem hiding this comment.
consider putting space before the 4, 7, to make things line up
There was a problem hiding this comment.
again, consider spacing these lines out so they line up.
There was a problem hiding this comment.
again, consider spacing these lines out so they line up.
I was already considering improving the alignments, like this one and the one you noted above. So with your endorsement I will probably not have to resist the temptation to do it any further ;-).
|
I just added the WIP marker. |
67d1ba8 to
fffac34
Compare
|
Ok, that's enough for today. Please let me know whether the rigorous alignment of formulas in commit 43e0e6a8d5669d60c9f9b3a48fe96b5b57d3ba77 improves readablility or whether it should be reverted. (currently, the alignment is only partially done). |
|
I think this is more readable, thanks!
|
7ce806c to
2fe09bf
Compare
|
Out of WIP, ready for final review. In the end all commits except for the last one will be squashed into a single one with the following commit message: The last commit is a little different, so it will be kept separate from the others: |
There was a problem hiding this comment.
Shouldn't there be at least one space either side of each +?
There was a problem hiding this comment.
Strictly speaking, it should... however, I'd like to see an exception here, in the interest of keeping the matrix look and thereby avoiding broken lines if we can.
There was a problem hiding this comment.
Elsewhere we have similar expressions that do have the spaces. If we want to avoid the broken lines, I'd rather add the spaces and exceed the 80 character limit.
There was a problem hiding this comment.
Yes, I overlooked this one. Fixup follows.
There was a problem hiding this comment.
Shouldn't a6 be lined up with c6? Similar comment for lines below.
There was a problem hiding this comment.
Also, if an expression is broken into several lines, we prefer to have the lines broken before an operator rather than after, i.e. that pair of lines should be:
s6 = c6 + a0 * b6 + a1 * b5 + a2 * b4 + a3 * b3 + a4 * b2 + a5 * b1
+ a6 * b0;
However, @mattcaswell, I fear that perfect alignment of variables competes with our requiring 4 space indent of the broken lines.
There was a problem hiding this comment.
I fear that perfect alignment of variables competes with our requiring 4 space indent of the broken lines.
Is that a requirement??
There was a problem hiding this comment.
Hmm... in this hunk I didn't do any aligning (yet), I only shortened overly long lines, which went from 80 to 82 bytes by the reindentation. I kept the original indation of 4 bytes for followup lines. You can see this nicely in 9c8ffa6?diff=split.
I could align the followup lines, but then I would have to do this for the entire block. Also note that there are different types of lines, the ones starting with a carry
openssl/crypto/ec/curve25519.c
Lines 4989 to 4992 in 9c8ffa6
and the ones without:
openssl/crypto/ec/curve25519.c
Lines 5005 to 5008 in 9c8ffa6
If I would indent 5 bytes instead of 4, the * operators would align nicely in the latter case, but in the former the * operators would align with + operators which does not make sense. That's why I left it unchanged. But If you think it is better that way, or if you have an alternative proposal, I'm open for suggestions.
There was a problem hiding this comment.
I fear that perfect alignment of variables competes with our requiring 4 space indent of the broken lines.
Is that a requirement??
@levitte @mattcaswell hang on for a minute, I think I found a nice compromise...
|
I have two alternative variants to offer
Yes, I know that variant 2 is far from all coding guidelines. But from a mathematical viewpoint it makes sense, because it emphasizes the the structure of the formula. Edit: sorry, I had to swap the commit ids, they were in the wrong order |
|
The full beauty unfolds only without the whitespace fine diffs: Variant 1 Variant 2 |
|
Needless to say that I prefer variant 2 ;-) |
My last suggestion (I promise!): also with right justified lhs operands, but more compact (128 columns): Variant 5 |
|
"To 3 or not to 3, that's the question" 🤣 (i.e variants 5 and 3 are my favorites, in that order) |
|
Oh wait, so breaking those lines isn't an option any more? |
|
All variants can be voted on. Variants 5 and 3 are my favorites, but I will follow your's and Matts advice. |
|
Ah, ok. It looks like I did not fully understand your suggestion #7750 (comment). |
|
Personally I prefer 4 in spite of the line length. But 5 would be acceptable. |
|
I agree with @mattcaswell, of all variants, I like 4 best. Regarding breaking lines, I dunno what to say. Our coding style says 80 columns, but on the other hand, it seems we've already accepted exceptions to the rules in this file, so... |
That's ok for me, I'll choose variant 4.
@richsalz made a very solominic comment w.r.t. this rule in #7750 (comment) |
86d13ed to
fdbab61
Compare
|
See fdbab61. |
|
Here is a link to the current state of curve25519.c. |
|
Matt, I have one final fixup: When taking a final look at curve25519.c, I noticed these constants openssl/crypto/ec/curve25519.c Lines 762 to 765 in fdbab61 which inspired my to replace the hexadecimal numbers (which I converted from dezimal in fdbab61) by a symbolic constant, too. Please confirm 2fefd39. |
Fixes #7698 Reviewed-by: Matt Caswell <[email protected]> (Merged from #7750)
Reviewed-by: Matt Caswell <[email protected]> (Merged from #7750)
Fixes #7698 Reviewed-by: Matt Caswell <[email protected]> (Merged from #7750) (cherry picked from commit 3a17b9a)
Reviewed-by: Matt Caswell <[email protected]> (Merged from #7750) (cherry picked from commit 425dde5)
|
Merged, thanks! master: 1.1.1: (The cherry-pick succeeded without conflicts. My #7698 (comment) turned out to be fake news. It was just a layer 8 problem while using pick-to-branch.) |
|
For the record (and for fun) I restored the unsquashed and unmerged branch and rebased it onto 4ace4cc such that commit d4160bc94901 (the head of pr-reformat-curve25519-c) points to the same tree as commit 425dde5, and the same holds for commits 3a17b9a and 45b75f5a3d: commit 425dde5 -> df372e71aab600b40d3c0d883fba6df3a850392b commit d4160bc949 -> df372e71aab600b40d3c0d883fba6df3a850392b This proves the equivalence of the merged with the unsquashed branch and makes commit 3a17b9a decomposable: master 425dde5 curve25519.c: improve formula alignment pr-reformat-curve25519-c d4160bc949 curve25519.c: improve formula alignment |
|
Oh, interesting. The pull request has now become closed permanently, it can't be reopened and the commit view doesn't get updated anymore. That's probably because I force-pushed while it was closed. What a pity, but never mind, it's also something new I learned. Sorry if I created some noise on the notification area with my experiments ;-). |
Fixes #7698
I tried to reformat the code as gently as possible and to minimize unnessesary whitespace diffs. In particular I tried to preserve most of the tabular aligning in the formulas, even in case where the 80 column rule was violated, referring to the following exceptional rule in our coding guidelines:
(In fact, the golden rule of all coding guidelines mandates that they must serve readability and not vice versa...)
There is another rule which I didn't follow blindly, because I did not want to disturb the perfect formatting of the formulas:
IMHO this should be a should, not a must anyway. But if you insist on this rule, I can add one more fixup.
Editorial Note
I split the reformatting into simple comprehensible steps and I recommend reviewing the changes commit-by-commit, before looking at the total change set. In the end all commits will be squashed into a single one with the following commit message:
Update: the last commit will be kept separate from the others and not squashed