diff mbox series

[v11,10/29] net: move copy_filename() to new file net/net-common.c

Message ID bc7f7365861fb75269f30300d341dafea92d76b5.1727968902.git.jerome.forissier@linaro.org
State New
Headers show
Series Introduce the lwIP network stack | expand

Commit Message

Jerome Forissier Oct. 3, 2024, 3:22 p.m. UTC
copy_filename() can be useful when NET_LWIP is enabled, therefore
move it out of net/net.c which is built only when networking choice
is NET.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 net/Makefile     |  2 ++
 net/net-common.c | 13 +++++++++++++
 net/net.c        | 12 ------------
 3 files changed, 15 insertions(+), 12 deletions(-)
 create mode 100644 net/net-common.c

Comments

Ilias Apalodimas Oct. 4, 2024, 6:52 a.m. UTC | #1
On Thu, 3 Oct 2024 at 18:24, Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> copy_filename() can be useful when NET_LWIP is enabled, therefore
> move it out of net/net.c which is built only when networking choice
> is NET.
>
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
>  net/Makefile     |  2 ++
>  net/net-common.c | 13 +++++++++++++
>  net/net.c        | 12 ------------
>  3 files changed, 15 insertions(+), 12 deletions(-)
>  create mode 100644 net/net-common.c
>
> diff --git a/net/Makefile b/net/Makefile
> index 70eec8caf0d..a9cecee637a 100644
> --- a/net/Makefile
> +++ b/net/Makefile
> @@ -42,3 +42,5 @@ obj-$(CONFIG_CMD_WGET) += wget.o
>  CFLAGS_eth_common.o += -Wno-format-extra-args
>
>  endif
> +
> +obj-y += net-common.o

This seems to belong in the net-common split patch?

> diff --git a/net/net-common.c b/net/net-common.c
> new file mode 100644
> index 00000000000..a7f767d5e9c
> --- /dev/null
> +++ b/net/net-common.c
> @@ -0,0 +1,13 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +void copy_filename(char *dst, const char *src, int size)
> +{
> +       if (src && *src && (*src == '"')) {
> +               ++src;
> +               --size;
> +       }
> +
> +       while ((--size > 0) && src && *src && (*src != '"'))
> +               *dst++ = *src++;
> +       *dst = '\0';
> +}
> diff --git a/net/net.c b/net/net.c
> index 1e0b7c85624..c1d10a77b9e 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1689,18 +1689,6 @@ void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport, int sport,
>         ip->udp_xsum = 0;
>  }
>
> -void copy_filename(char *dst, const char *src, int size)
> -{
> -       if (src && *src && (*src == '"')) {
> -               ++src;
> -               --size;
> -       }
> -
> -       while ((--size > 0) && src && *src && (*src != '"'))
> -               *dst++ = *src++;
> -       *dst = '\0';
> -}
> -
>  int is_serverip_in_cmd(void)
>  {
>         return !!strchr(net_boot_file_name, ':');
> --
> 2.40.1
>

With the the above fixed
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Jerome Forissier Oct. 4, 2024, 8:01 a.m. UTC | #2
On 10/4/24 08:52, Ilias Apalodimas wrote:
> On Thu, 3 Oct 2024 at 18:24, Jerome Forissier
> <jerome.forissier@linaro.org> wrote:
>>
>> copy_filename() can be useful when NET_LWIP is enabled, therefore
>> move it out of net/net.c which is built only when networking choice
>> is NET.
>>
>> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
>> ---
>>  net/Makefile     |  2 ++
>>  net/net-common.c | 13 +++++++++++++
>>  net/net.c        | 12 ------------
>>  3 files changed, 15 insertions(+), 12 deletions(-)
>>  create mode 100644 net/net-common.c
>>
>> diff --git a/net/Makefile b/net/Makefile
>> index 70eec8caf0d..a9cecee637a 100644
>> --- a/net/Makefile
>> +++ b/net/Makefile
>> @@ -42,3 +42,5 @@ obj-$(CONFIG_CMD_WGET) += wget.o
>>  CFLAGS_eth_common.o += -Wno-format-extra-args
>>
>>  endif
>> +
>> +obj-y += net-common.o
> 
> This seems to belong in the net-common split patch?

The patch you're referring to only splits the headers. But yeah
it would probably make more sense to do this as well. I will combine
the two patches in v12.

>> diff --git a/net/net-common.c b/net/net-common.c
>> new file mode 100644
>> index 00000000000..a7f767d5e9c
>> --- /dev/null
>> +++ b/net/net-common.c
>> @@ -0,0 +1,13 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +void copy_filename(char *dst, const char *src, int size)
>> +{
>> +       if (src && *src && (*src == '"')) {
>> +               ++src;
>> +               --size;
>> +       }
>> +
>> +       while ((--size > 0) && src && *src && (*src != '"'))
>> +               *dst++ = *src++;
>> +       *dst = '\0';
>> +}
>> diff --git a/net/net.c b/net/net.c
>> index 1e0b7c85624..c1d10a77b9e 100644
>> --- a/net/net.c
>> +++ b/net/net.c
>> @@ -1689,18 +1689,6 @@ void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport, int sport,
>>         ip->udp_xsum = 0;
>>  }
>>
>> -void copy_filename(char *dst, const char *src, int size)
>> -{
>> -       if (src && *src && (*src == '"')) {
>> -               ++src;
>> -               --size;
>> -       }
>> -
>> -       while ((--size > 0) && src && *src && (*src != '"'))
>> -               *dst++ = *src++;
>> -       *dst = '\0';
>> -}
>> -
>>  int is_serverip_in_cmd(void)
>>  {
>>         return !!strchr(net_boot_file_name, ':');
>> --
>> 2.40.1
>>
> 
> With the the above fixed
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Thanks,
diff mbox series

Patch

diff --git a/net/Makefile b/net/Makefile
index 70eec8caf0d..a9cecee637a 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -42,3 +42,5 @@  obj-$(CONFIG_CMD_WGET) += wget.o
 CFLAGS_eth_common.o += -Wno-format-extra-args
 
 endif
+
+obj-y += net-common.o
diff --git a/net/net-common.c b/net/net-common.c
new file mode 100644
index 00000000000..a7f767d5e9c
--- /dev/null
+++ b/net/net-common.c
@@ -0,0 +1,13 @@ 
+// SPDX-License-Identifier: GPL-2.0
+
+void copy_filename(char *dst, const char *src, int size)
+{
+	if (src && *src && (*src == '"')) {
+		++src;
+		--size;
+	}
+
+	while ((--size > 0) && src && *src && (*src != '"'))
+		*dst++ = *src++;
+	*dst = '\0';
+}
diff --git a/net/net.c b/net/net.c
index 1e0b7c85624..c1d10a77b9e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1689,18 +1689,6 @@  void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport, int sport,
 	ip->udp_xsum = 0;
 }
 
-void copy_filename(char *dst, const char *src, int size)
-{
-	if (src && *src && (*src == '"')) {
-		++src;
-		--size;
-	}
-
-	while ((--size > 0) && src && *src && (*src != '"'))
-		*dst++ = *src++;
-	*dst = '\0';
-}
-
 int is_serverip_in_cmd(void)
 {
 	return !!strchr(net_boot_file_name, ':');