[U-Boot-Users] /* inside comment in libfdt.h

Hi,
I just tested the current master branch after Wolfgang recent custodian merge and noticed some errors that are caused by comments inside comments.
Possibly this can be switched of by a compiler switch or the code has never passed compilation. With ELDK's gcc 4.0.0 (ELDK 4.1.0) at least I run into trouble.
What about this solution:
diff --git a/include/libfdt.h b/include/libfdt.h index 8253ccf..8050049 100644 --- a/include/libfdt.h +++ b/include/libfdt.h @@ -544,7 +544,7 @@ int fdt_parent_offset(const void *fdt, int nodeoffset); * offset = fdt_node_offset_by_prop_value(fdt, -1, propname, * propval, proplen); * while (offset != -FDT_ERR_NOTFOUND) { - * /* other code here */ + * ... other code here ... * offset = fdt_node_offset_by_prop_value(fdt, offset, propname, * propval, proplen); * } @@ -629,7 +629,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, * idiom can be used: * offset = fdt_node_offset_by_compatible(fdt, -1, compatible); * while (offset != -FDT_ERR_NOTFOUND) { - * /* other code here */ + * ... other code here ... * offset = fdt_node_offset_by_compatible(fdt, offset, compatible); * } *
Matthias

Matthias Fuchs wrote:
Hi,
I just tested the current master branch after Wolfgang recent custodian merge and noticed some errors that are caused by comments inside comments.
Possibly this can be switched of by a compiler switch or the code has never passed compilation. With ELDK's gcc 4.0.0 (ELDK 4.1.0) at least I run into trouble.
What about this solution:
diff --git a/include/libfdt.h b/include/libfdt.h index 8253ccf..8050049 100644 --- a/include/libfdt.h +++ b/include/libfdt.h @@ -544,7 +544,7 @@ int fdt_parent_offset(const void *fdt, int nodeoffset);
offset = fdt_node_offset_by_prop_value(fdt, -1, propname,
propval, proplen);
while (offset != -FDT_ERR_NOTFOUND) {
/* other code here */
... other code here ...
offset = fdt_node_offset_by_prop_value(fdt, offset, propname,
propval, proplen);
}
@@ -629,7 +629,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
- idiom can be used:
offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
while (offset != -FDT_ERR_NOTFOUND) {
/* other code here */
... other code here ...
offset = fdt_node_offset_by_compatible(fdt, offset, compatible);
}
Matthias
Yes, nested comments is something that should not be done and should be fixed. This was inherited from the original code, although the current version uses // for the embedded comment which avoids the issue (but causes "no C++ comments" people to break out in rashes).
Hmm, interesting, the original appears to have always used //, so it would appear that we (u-booties) did the change to /* */. http://jdl.com/git_repos/?p=dtc.git;a=commitdiff;h=53acf491e9d576519f97b62984762498f9453cb4 I'll have to look at this further.
My inclination is to change to embedded // comments to avoid drifting from the original due to aesthetics rather than due to necessary functionality differences.
The alternative would be to convince David Gibson (/jdl) to adopt the ...other code here... change. I prefer the ... change if it matters - if somebody blindly cuts and pastes the example code, it won't compile until he understands and edits what he pasted.
Thanks, gvb

On Wednesday 02 January 2008 14:13, Jerry Van Baren wrote:
C++ style comments inside comments are no comments :-)
I could life with //, but if people do cut'n'paste we get // in our code - and 'ubooties' know not to use C++ style comments.
When the original source uses //, we should keep that in order to stay in sync with that code. If the U-Boot community will start to stone us, the solution is ....
Wolfgang, do you accept the change back to //?
Matthias
Yes, nested comments is something that should not be done and should be fixed. This was inherited from the original code, although the current version uses // for the embedded comment which avoids the issue (but causes "no C++ comments" people to break out in rashes).
Hmm, interesting, the original appears to have always used //, so it would appear that we (u-booties) did the change to /* */. http://jdl.com/git_repos/?p=dtc.git;a=commitdiff;h=53acf491e9d576519f97b62984762498f9453cb4 I'll have to look at this further.
My inclination is to change to embedded // comments to avoid drifting from the original due to aesthetics rather than due to necessary functionality differences.
The alternative would be to convince David Gibson (/jdl) to adopt the ...other code here... change. I prefer the ... change if it matters - if somebody blindly cuts and pastes the example code, it won't compile until he understands and edits what he pasted.
Thanks, gvb

On Wed, 2008-01-02 at 07:13, Jerry Van Baren wrote:
Yes, nested comments is something that should not be done and should be fixed. This was inherited from the original code, although the current version uses // for the embedded comment which avoids the issue (but causes "no C++ comments" people to break out in rashes).
Woah, hey! That's me!
Uh...
Hmm, interesting, the original appears to have always used //, so it would appear that we (u-booties) did the change to /* */. http://jdl.com/git_repos/?p=dtc.git;a=commitdiff;h=53acf491e9d576519f97b62984762498f9453cb4 I'll have to look at this further.
My inclination is to change to embedded // comments to avoid drifting from the original due to aesthetics rather than due to necessary functionality differences.
The alternative would be to convince David Gibson (/jdl) to adopt the ...other code here... change. I prefer the ... change if it matters - if somebody blindly cuts and pastes the example code, it won't compile until he understands and edits what he pasted.
Oh man....
OK. For the record, I'm all for only comments like this:
/* * */
Clearly lax, I'll start enforcing it on the DTC sources more.
Sorry.
jdl

Jon Loeliger wrote:
Oh man....
OK. For the record, I'm all for only comments like this:
/* * */
Clearly lax, I'll start enforcing it on the DTC sources more.
Sorry.
Yes, because putting up with the inability to nest comments is clearly worth avoiding something that came from a language with cooties.
-Scott

Jon Loeliger wrote:
On Wed, 2008-01-02 at 07:13, Jerry Van Baren wrote:
Yes, nested comments is something that should not be done and should be fixed. This was inherited from the original code, although the current version uses // for the embedded comment which avoids the issue (but causes "no C++ comments" people to break out in rashes).
Woah, hey! That's me!
Uh...
Stop. Take a deep breath. It really wasn't you, just had your fingerprints because you touched it last. I referenced your repository as the convenient/canonical repository for dtc/libfdt.
[snip]
Oh man....
OK. For the record, I'm all for only comments like this:
/* * */
Clearly lax, I'll start enforcing it on the DTC sources more.
Sorry.
jdl
FWIIW, the misdeed was the sample code embedded inside the comment had a (sample) commented line "// add code here" which was done with a C++ // comment so that it didn't run afoul of the C compiler's no nested comments rule. A certain dignitary who breaks out in a rash when he sees // comments made a "trivial" change to a /* */ comment, which then caused the C compiler to throw a hissy fit because it now *was* a nested comment.
All in all, a comedy of good intentions. No Code Was Harmed(R) in the making of this patch sequence.
HTH, gvb
(R) http://www.americanhumane.org/site/PageServer?pagename=faqs_film_end_credit
P.S. :-D, but you knew that already.

On Thu, Jan 03, 2008 at 02:47:11PM -0500, Jerry Van Baren wrote:
Jon Loeliger wrote:
On Wed, 2008-01-02 at 07:13, Jerry Van Baren wrote: Oh man.... OK. For the record, I'm all for only comments like this: /* * */ Clearly lax, I'll start enforcing it on the DTC sources more. Sorry. jdl
FWIIW, the misdeed was the sample code embedded inside the comment had a (sample) commented line "// add code here" which was done with a C++ // comment so that it didn't run afoul of the C compiler's no nested comments rule. A certain dignitary who breaks out in a rash when he sees // comments made a "trivial" change to a /* */ comment, which then caused the C compiler to throw a hissy fit because it now *was* a nested comment.
All in all, a comedy of good intentions. No Code Was Harmed(R) in the making of this patch sequence.
Oh dear. Yes, I believe those '//' were deliberate to avoid nested comments. Think of them as pseudo-code, not C++ if that makes it any more palatable.

Hi you guys,
I love reading this list. Thanks Matthias - for making this thread possible.
Wolfgang, what about a 'best thread of the month/year' award.
:-) Matthias

Matthias Fuchs wrote:
Hi you guys,
I love reading this list. Thanks Matthias - for making this thread possible.
Wolfgang, what about a 'best thread of the month/year' award.
:-) Matthias
Calvin: "I try to make everyone's day a little more surreal." The Essential Calvin and Hobbes, p152-3 http://www.calvin-and-hobbes.org/information/quotes
:-D gvb

On Fri, 2008-01-04 at 04:24, Matthias Fuchs wrote:
Hi you guys,
I love reading this list. Thanks Matthias - for making this thread possible.
Wolfgang, what about a 'best thread of the month/year' award.
:-) Matthias
Man, we're only 3 or 4 days into the year and I'm already participating in Award Nominatable Mail Threads!
Sweet.
jdl

In message 200801021347.01153.matthias.fuchs@esd-electronics.com you wrote:
I just tested the current master branch after Wolfgang recent custodian merge and noticed some errors that are caused by comments inside comments.
Possibly this can be switched of by a compiler switch or the code has never passed compilation. With ELDK's gcc 4.0.0 (ELDK 4.1.0) at least I run into trouble.
You are right, mea culpa. Fix is checked in.
Best regards,
Wolfgang Denk
participants (6)
-
David Gibson
-
Jerry Van Baren
-
Jon Loeliger
-
Matthias Fuchs
-
Scott Wood
-
Wolfgang Denk