diff mbox series

nfs-utils: Fix const qualifier error

Message ID 1734597713-2663-1-git-send-email-wangmy@fujitsu.com
State New
Headers show
Series nfs-utils: Fix const qualifier error | expand

Commit Message

Mingyu Wang (Fujitsu) Dec. 19, 2024, 8:41 a.m. UTC
From: Wang Mingyu <wangmy@cn.fujitsu.com>

error with clang:
file.c:200:8: error: assigning to 'char *' from 'const char *'
discards qualifiers
[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
|   200 |                 base = pathname;
|       |                      ^ ~~~~~~~~

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 .../0001-Fix-const-qualifier-error.patch      | 35 +++++++++++++++++++
 .../nfs-utils/nfs-utils_2.8.2.bb              |  1 +
 2 files changed, 36 insertions(+)
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch

Comments

Alexander Kanavin Dec. 19, 2024, 9 a.m. UTC | #1
Please do not add new ‘Penfing’ patches. They should be submitted upstream
first or there should be an explanation of what is pending.

Alex

On Thu 19. Dec 2024 at 9.42, wangmy via lists.openembedded.org <wangmy=
fujitsu.com@lists.openembedded.org> wrote:

> From: Wang Mingyu <wangmy@cn.fujitsu.com>
>
> error with clang:
> file.c:200:8: error: assigning to 'char *' from 'const char *'
> discards qualifiers
> [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
> |   200 |                 base = pathname;
> |       |                      ^ ~~~~~~~~
>
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  .../0001-Fix-const-qualifier-error.patch      | 35 +++++++++++++++++++
>  .../nfs-utils/nfs-utils_2.8.2.bb              |  1 +
>  2 files changed, 36 insertions(+)
>  create mode 100644
> meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
>
> diff --git
> a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
> b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
> new file mode 100644
> index 0000000000..8fc327e7aa
> --- /dev/null
> +++
> b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
> @@ -0,0 +1,35 @@
> +From a21344466e4c315d6d7098920819983f2d15573b Mon Sep 17 00:00:00 2001
> +From: Wang Mingyu <wangmy@cn.fujitsu.com>
> +Date: Thu, 19 Dec 2024 06:18:59 +0000
> +Subject: [PATCH] Fix const qualifier error
> +
> +Fixes clang error
> +file.c:200:8: error: assigning to 'char *' from 'const char *'
> +discards qualifiers
> +[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
> +|   200 |                 base = pathname;
> +|       |                      ^ ~~~~~~~~
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> +---
> + support/nsm/file.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/support/nsm/file.c b/support/nsm/file.c
> +index de122b0..2733210 100644
> +--- a/support/nsm/file.c
> ++++ b/support/nsm/file.c
> +@@ -197,7 +197,7 @@ nsm_make_temp_pathname(const char *pathname)
> +
> +       base = strrchr(pathname, '/');
> +       if (base == NULL)
> +-              base = pathname;
> ++              base = (char*)(&pathname);
> +       else
> +               base++;
> +
> +--
> +2.43.0
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
> b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
> index 543c68f7f5..45821b98e8 100644
> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
> @@ -31,6 +31,7 @@ SRC_URI =
> "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
>
> file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
>             file://clang-warnings.patch \
>             file://0001-locktest-Makefile.am-Do-not-use-build-flags.patch \
> +           file://0001-Fix-const-qualifier-error.patch \
>             "
>
>  SRC_URI[sha256sum] =
> "a39bbea76ac0ab9e6e8699caf3c308b6b310c20d458e8fa8606196d358e7fb15"
> --
> 2.43.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#208898):
> https://lists.openembedded.org/g/openembedded-core/message/208898
> Mute This Topic: https://lists.openembedded.org/mt/110195053/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Khem Raj Dec. 19, 2024, 6:05 p.m. UTC | #2
On Thu, Dec 19, 2024 at 1:01 AM Alexander Kanavin via
lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org>
wrote:
>
> Please do not add new ‘Penfing’ patches. They should be submitted upstream first or there should be an explanation of what is pending.

Yeah, i did another patch which is also not correct sadly. Perhaps we
need to address it differently than simply trying
type punning.

>
> Alex
>
> On Thu 19. Dec 2024 at 9.42, wangmy via lists.openembedded.org <wangmy=fujitsu.com@lists.openembedded.org> wrote:
>>
>> From: Wang Mingyu <wangmy@cn.fujitsu.com>
>>
>> error with clang:
>> file.c:200:8: error: assigning to 'char *' from 'const char *'
>> discards qualifiers
>> [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
>> |   200 |                 base = pathname;
>> |       |                      ^ ~~~~~~~~
>>
>> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
>> ---
>>  .../0001-Fix-const-qualifier-error.patch      | 35 +++++++++++++++++++
>>  .../nfs-utils/nfs-utils_2.8.2.bb              |  1 +
>>  2 files changed, 36 insertions(+)
>>  create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
>>
>> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
>> new file mode 100644
>> index 0000000000..8fc327e7aa
>> --- /dev/null
>> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
>> @@ -0,0 +1,35 @@
>> +From a21344466e4c315d6d7098920819983f2d15573b Mon Sep 17 00:00:00 2001
>> +From: Wang Mingyu <wangmy@cn.fujitsu.com>
>> +Date: Thu, 19 Dec 2024 06:18:59 +0000
>> +Subject: [PATCH] Fix const qualifier error
>> +
>> +Fixes clang error
>> +file.c:200:8: error: assigning to 'char *' from 'const char *'
>> +discards qualifiers
>> +[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
>> +|   200 |                 base = pathname;
>> +|       |                      ^ ~~~~~~~~
>> +
>> +Upstream-Status: Pending
>> +
>> +Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
>> +---
>> + support/nsm/file.c | 2 +-
>> + 1 file changed, 1 insertion(+), 1 deletion(-)
>> +
>> +diff --git a/support/nsm/file.c b/support/nsm/file.c
>> +index de122b0..2733210 100644
>> +--- a/support/nsm/file.c
>> ++++ b/support/nsm/file.c
>> +@@ -197,7 +197,7 @@ nsm_make_temp_pathname(const char *pathname)
>> +
>> +       base = strrchr(pathname, '/');
>> +       if (base == NULL)
>> +-              base = pathname;
>> ++              base = (char*)(&pathname);
>> +       else
>> +               base++;
>> +
>> +--
>> +2.43.0
>> +
>> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
>> index 543c68f7f5..45821b98e8 100644
>> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
>> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
>> @@ -31,6 +31,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
>>             file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
>>             file://clang-warnings.patch \
>>             file://0001-locktest-Makefile.am-Do-not-use-build-flags.patch \
>> +           file://0001-Fix-const-qualifier-error.patch \
>>             "
>>
>>  SRC_URI[sha256sum] = "a39bbea76ac0ab9e6e8699caf3c308b6b310c20d458e8fa8606196d358e7fb15"
>> --
>> 2.43.0
>>
>>
>>
>>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#208899): https://lists.openembedded.org/g/openembedded-core/message/208899
> Mute This Topic: https://lists.openembedded.org/mt/110195053/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj Dec. 19, 2024, 7:20 p.m. UTC | #3
On Thu, Dec 19, 2024 at 10:05 AM Khem Raj <raj.khem@gmail.com> wrote:
>
> On Thu, Dec 19, 2024 at 1:01 AM Alexander Kanavin via
> lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org>
> wrote:
> >
> > Please do not add new ‘Penfing’ patches. They should be submitted upstream first or there should be an explanation of what is pending.
>
> Yeah, i did another patch which is also not correct sadly. Perhaps we
> need to address it differently than simply trying
> type punning.
>

looking a bit closer, it seems changing the type of base from char* to
const char* is enough to get types correct. I have send a v2 patch
to upstream as well as for oe-core.

> >
> > Alex
> >
> > On Thu 19. Dec 2024 at 9.42, wangmy via lists.openembedded.org <wangmy=fujitsu.com@lists.openembedded.org> wrote:
> >>
> >> From: Wang Mingyu <wangmy@cn.fujitsu.com>
> >>
> >> error with clang:
> >> file.c:200:8: error: assigning to 'char *' from 'const char *'
> >> discards qualifiers
> >> [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
> >> |   200 |                 base = pathname;
> >> |       |                      ^ ~~~~~~~~
> >>
> >> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> >> ---
> >>  .../0001-Fix-const-qualifier-error.patch      | 35 +++++++++++++++++++
> >>  .../nfs-utils/nfs-utils_2.8.2.bb              |  1 +
> >>  2 files changed, 36 insertions(+)
> >>  create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
> >>
> >> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
> >> new file mode 100644
> >> index 0000000000..8fc327e7aa
> >> --- /dev/null
> >> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
> >> @@ -0,0 +1,35 @@
> >> +From a21344466e4c315d6d7098920819983f2d15573b Mon Sep 17 00:00:00 2001
> >> +From: Wang Mingyu <wangmy@cn.fujitsu.com>
> >> +Date: Thu, 19 Dec 2024 06:18:59 +0000
> >> +Subject: [PATCH] Fix const qualifier error
> >> +
> >> +Fixes clang error
> >> +file.c:200:8: error: assigning to 'char *' from 'const char *'
> >> +discards qualifiers
> >> +[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
> >> +|   200 |                 base = pathname;
> >> +|       |                      ^ ~~~~~~~~
> >> +
> >> +Upstream-Status: Pending
> >> +
> >> +Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> >> +---
> >> + support/nsm/file.c | 2 +-
> >> + 1 file changed, 1 insertion(+), 1 deletion(-)
> >> +
> >> +diff --git a/support/nsm/file.c b/support/nsm/file.c
> >> +index de122b0..2733210 100644
> >> +--- a/support/nsm/file.c
> >> ++++ b/support/nsm/file.c
> >> +@@ -197,7 +197,7 @@ nsm_make_temp_pathname(const char *pathname)
> >> +
> >> +       base = strrchr(pathname, '/');
> >> +       if (base == NULL)
> >> +-              base = pathname;
> >> ++              base = (char*)(&pathname);
> >> +       else
> >> +               base++;
> >> +
> >> +--
> >> +2.43.0
> >> +
> >> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
> >> index 543c68f7f5..45821b98e8 100644
> >> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
> >> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
> >> @@ -31,6 +31,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
> >>             file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
> >>             file://clang-warnings.patch \
> >>             file://0001-locktest-Makefile.am-Do-not-use-build-flags.patch \
> >> +           file://0001-Fix-const-qualifier-error.patch \
> >>             "
> >>
> >>  SRC_URI[sha256sum] = "a39bbea76ac0ab9e6e8699caf3c308b6b310c20d458e8fa8606196d358e7fb15"
> >> --
> >> 2.43.0
> >>
> >>
> >>
> >>
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#208899): https://lists.openembedded.org/g/openembedded-core/message/208899
> > Mute This Topic: https://lists.openembedded.org/mt/110195053/1997914
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
diff mbox series

Patch

diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
new file mode 100644
index 0000000000..8fc327e7aa
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Fix-const-qualifier-error.patch
@@ -0,0 +1,35 @@ 
+From a21344466e4c315d6d7098920819983f2d15573b Mon Sep 17 00:00:00 2001
+From: Wang Mingyu <wangmy@cn.fujitsu.com>
+Date: Thu, 19 Dec 2024 06:18:59 +0000
+Subject: [PATCH] Fix const qualifier error
+
+Fixes clang error
+file.c:200:8: error: assigning to 'char *' from 'const char *'
+discards qualifiers
+[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
+|   200 |                 base = pathname;
+|       |                      ^ ~~~~~~~~
+
+Upstream-Status: Pending
+
+Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
+---
+ support/nsm/file.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/support/nsm/file.c b/support/nsm/file.c
+index de122b0..2733210 100644
+--- a/support/nsm/file.c
++++ b/support/nsm/file.c
+@@ -197,7 +197,7 @@ nsm_make_temp_pathname(const char *pathname)
+ 
+ 	base = strrchr(pathname, '/');
+ 	if (base == NULL)
+-		base = pathname;
++		base = (char*)(&pathname);
+ 	else
+ 		base++;
+ 
+-- 
+2.43.0
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
index 543c68f7f5..45821b98e8 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb
@@ -31,6 +31,7 @@  SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
            file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
            file://clang-warnings.patch \
            file://0001-locktest-Makefile.am-Do-not-use-build-flags.patch \
+           file://0001-Fix-const-qualifier-error.patch \
            "
 
 SRC_URI[sha256sum] = "a39bbea76ac0ab9e6e8699caf3c308b6b310c20d458e8fa8606196d358e7fb15"