Bug 261930

Summary: sysutils/dtc: fix build with clang 14
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Dimitry Andric <dim>
Status: Closed FIXED    
Severity: Affects Some People CC: uboot
Priority: --- Flags: bugzilla: maintainer-feedback? (uboot)
koobs: merge-quarterly+
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 261742    
Attachments:
Description Flags
Fix clang 14 warning about use of bitwise logical operator none

Description Dimitry Andric freebsd_committer freebsd_triage 2022-02-13 13:58:28 UTC
During an exp-run for llvm 14 (see bug 261742), it turned out that sysutils/dtc fails to build with clang 14:

libfdt/fdt_rw.c:438:6: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
        if (can_assume(LIBFDT_ORDER) |
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                     ||
libfdt/libfdt_internal.h:171:29: note: expanded from macro 'can_assume'
#define can_assume(_assume)     can_assume_(ASSUME_ ## _assume)
                                ^
libfdt/fdt_rw.c:438:6: note: cast one or both operands to int to silence this warning
libfdt/libfdt_internal.h:171:29: note: expanded from macro 'can_assume'
#define can_assume(_assume)     can_assume_(ASSUME_ ## _assume)
                                ^
1 error generated.

This looks like a bug in dtc, it should quite obviously use a logical || instead of a bitwise | here. I will attach at patch to this bug.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2022-02-13 14:02:58 UTC
Created attachment 231793 [details]
Fix clang 14 warning about use of bitwise logical operator
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2022-02-19 19:05:47 UTC
Upstream did exactly the same fix, here:
https://github.com/dgibson/dtc/commit/7be250b4d059771c47be00ec8d4df7f47e4ac77c
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-03-10 19:55:44 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7f2fdcb022ca2f4ff3f34829a4539463bdfd390d

commit 7f2fdcb022ca2f4ff3f34829a4539463bdfd390d
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-02-13 14:01:05 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-03-10 19:53:43 +0000

    sysutils/dtc: fix clang 14 warning about use of bitwise logical operator

    During an exp-run for llvm 14 (see bug 261742), it turned out that
    sysutils/dtc fails to build with clang 14:

    libfdt/fdt_rw.c:438:6: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
            if (can_assume(LIBFDT_ORDER) |
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                         ||
    libfdt/libfdt_internal.h:171:29: note: expanded from macro 'can_assume'
                                    ^
    libfdt/fdt_rw.c:438:6: note: cast one or both operands to int to silence this warning
    libfdt/libfdt_internal.h:171:29: note: expanded from macro 'can_assume'
                                    ^

    This should have been a logical or instead. Upstream fixed this in:
    https://github.com/dgibson/dtc/commit/7be250b4d059771c47be00ec8d4df7f47e4ac77c

    PR:             261930
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2022Q1

 sysutils/dtc/files/patch-libfdt_fdt__rw.c (new) | 11 +++++++++++
 1 file changed, 11 insertions(+)