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

Jerry Van Baren gerald.vanbaren at ge.com
Wed Jan 2 14:13:10 CET 2008


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).

<http://jdl.com/git_repos/?p=dtc.git;a=blob;f=libfdt/libfdt.h;h=ac0f5c3d1b41a1f6a8a5637a11d3ae4b9b6e6ed4;hb=3e516d961a45a2a410a9dc8f61fbdd62641b5ca0#l547>

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




More information about the U-Boot mailing list