2014-12-09 15:48:32

by Vitaly Kuznetsov

[permalink] [raw]
Subject: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup

When someone does 'make' in tools/hv/ issues appear:
- hv_fcopy_daemon is not being built;
- lots of compiler warnings.

This is just a cleanup. Compile-tested by myself on top of linux-next/master.

Piggyback this series and send "[PATCH 5/5] Tools: hv: do not add redundant '/'
in hv_start_fcopy()"

Vitaly Kuznetsov (5):
Tools: hv: add mising fcopyd to the Makefile
Tools: hv: remove unused bytes_written from kvp_update_file()
Tools: hv: address compiler warnings for hv_kvp_daemon.c
Tools: hv: address compiler warnings for hv_fcopy_daemon.c
Tools: hv: do not add redundant '/' in hv_start_fcopy()

tools/hv/Makefile | 4 ++--
tools/hv/hv_fcopy_daemon.c | 10 ++--------
tools/hv/hv_kvp_daemon.c | 29 +++++++++++++----------------
3 files changed, 17 insertions(+), 26 deletions(-)

--
1.9.3


2014-12-09 15:48:37

by Vitaly Kuznetsov

[permalink] [raw]
Subject: [PATCH 1/5] Tools: hv: add mising fcopyd to the Makefile

fcopyd in missing in the Makefile, add it there.

Signed-off-by: Vitaly Kuznetsov <[email protected]>
---
tools/hv/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/hv/Makefile b/tools/hv/Makefile
index bd22f78..99ffe61 100644
--- a/tools/hv/Makefile
+++ b/tools/hv/Makefile
@@ -5,9 +5,9 @@ PTHREAD_LIBS = -lpthread
WARNINGS = -Wall -Wextra
CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS)

-all: hv_kvp_daemon hv_vss_daemon
+all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
%: %.c
$(CC) $(CFLAGS) -o $@ $^

clean:
- $(RM) hv_kvp_daemon hv_vss_daemon
+ $(RM) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
--
1.9.3

2014-12-09 15:48:47

by Vitaly Kuznetsov

[permalink] [raw]
Subject: [PATCH 5/5] Tools: hv: do not add redundant '/' in hv_start_fcopy()

We don't need to add additional '/' to smsg->path_name as snprintf("%s/%s")
does the right thing. Without the patch we get doubled '//' in the log message.

Signed-off-by: Vitaly Kuznetsov <[email protected]>
---
tools/hv/hv_fcopy_daemon.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index 1a23872..9445d8f 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -43,12 +43,6 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
int error = HV_E_FAIL;
char *q, *p;

- /*
- * If possile append a path seperator to the path.
- */
- if (strlen((char *)smsg->path_name) < (W_MAX_PATH - 2))
- strcat((char *)smsg->path_name, "/");
-
p = (char *)smsg->path_name;
snprintf(target_fname, sizeof(target_fname), "%s/%s",
(char *)smsg->path_name, (char *)smsg->file_name);
--
1.9.3

2014-12-09 15:48:39

by Vitaly Kuznetsov

[permalink] [raw]
Subject: [PATCH 2/5] Tools: hv: remove unused bytes_written from kvp_update_file()

fwrite() does not actually return the number of bytes written and
this value is being ignored anyway and ferror() is being called to
check for an error. As we assign to this variable and never use it
we get the following compile-time warning:
hv_kvp_daemon.c:149:9: warning: variable ‘bytes_written’ set but not used [-Wunused-but-set-variable]

Remove bytes_written completely.

Signed-off-by: Vitaly Kuznetsov <[email protected]>
---
tools/hv/hv_kvp_daemon.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 6a6432a..5a274ca 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -147,7 +147,6 @@ static void kvp_release_lock(int pool)
static void kvp_update_file(int pool)
{
FILE *filep;
- size_t bytes_written;

/*
* We are going to write our in-memory registry out to
@@ -163,8 +162,7 @@ static void kvp_update_file(int pool)
exit(EXIT_FAILURE);
}

- bytes_written = fwrite(kvp_file_info[pool].records,
- sizeof(struct kvp_record),
+ fwrite(kvp_file_info[pool].records, sizeof(struct kvp_record),
kvp_file_info[pool].num_records, filep);

if (ferror(filep) || fclose(filep)) {
--
1.9.3

2014-12-09 15:48:36

by Vitaly Kuznetsov

[permalink] [raw]
Subject: [PATCH 3/5] Tools: hv: address compiler warnings for hv_kvp_daemon.c

This patch addresses two types of compiler warnings:
... warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
and
... warning: pointer targets in passing argument N of ‘kvp_...’ differ in signedness [-Wpointer-sign]

Signed-off-by: Vitaly Kuznetsov <[email protected]>
---
tools/hv/hv_kvp_daemon.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 5a274ca..48a95f9 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -308,7 +308,7 @@ static int kvp_file_init(void)
return 0;
}

-static int kvp_key_delete(int pool, const char *key, int key_size)
+static int kvp_key_delete(int pool, const __u8 *key, int key_size)
{
int i;
int j, k;
@@ -351,8 +351,8 @@ static int kvp_key_delete(int pool, const char *key, int key_size)
return 1;
}

-static int kvp_key_add_or_modify(int pool, const char *key, int key_size, const char *value,
- int value_size)
+static int kvp_key_add_or_modify(int pool, const __u8 *key, int key_size,
+ const __u8 *value, int value_size)
{
int i;
int num_records;
@@ -405,7 +405,7 @@ static int kvp_key_add_or_modify(int pool, const char *key, int key_size, const
return 0;
}

-static int kvp_get_value(int pool, const char *key, int key_size, char *value,
+static int kvp_get_value(int pool, const __u8 *key, int key_size, __u8 *value,
int value_size)
{
int i;
@@ -437,8 +437,8 @@ static int kvp_get_value(int pool, const char *key, int key_size, char *value,
return 1;
}

-static int kvp_pool_enumerate(int pool, int index, char *key, int key_size,
- char *value, int value_size)
+static int kvp_pool_enumerate(int pool, int index, __u8 *key, int key_size,
+ __u8 *value, int value_size)
{
struct kvp_record *record;

@@ -659,7 +659,7 @@ static char *kvp_if_name_to_mac(char *if_name)
char *p, *x;
char buf[256];
char addr_file[256];
- int i;
+ unsigned int i;
char *mac_addr = NULL;

snprintf(addr_file, sizeof(addr_file), "%s%s%s", "/sys/class/net/",
@@ -698,7 +698,7 @@ static char *kvp_mac_to_if_name(char *mac)
char buf[256];
char *kvp_net_dir = "/sys/class/net/";
char dev_id[256];
- int i;
+ unsigned int i;

dir = opendir(kvp_net_dir);
if (dir == NULL)
@@ -748,7 +748,7 @@ static char *kvp_mac_to_if_name(char *mac)


static void kvp_process_ipconfig_file(char *cmd,
- char *config_buf, int len,
+ char *config_buf, unsigned int len,
int element_size, int offset)
{
char buf[256];
@@ -766,7 +766,7 @@ static void kvp_process_ipconfig_file(char *cmd,
if (offset == 0)
memset(config_buf, 0, len);
while ((p = fgets(buf, sizeof(buf), file)) != NULL) {
- if ((len - strlen(config_buf)) < (element_size + 1))
+ if (len < strlen(config_buf) + element_size + 1)
break;

x = strchr(p, '\n');
@@ -914,7 +914,7 @@ static int kvp_process_ip_address(void *addrp,

static int
kvp_get_ip_info(int family, char *if_name, int op,
- void *out_buffer, int length)
+ void *out_buffer, unsigned int length)
{
struct ifaddrs *ifap;
struct ifaddrs *curp;
@@ -1017,8 +1017,7 @@ kvp_get_ip_info(int family, char *if_name, int op,
weight += hweight32(&w[i]);

sprintf(cidr_mask, "/%d", weight);
- if ((length - sn_offset) <
- (strlen(cidr_mask) + 1))
+ if (length < sn_offset + strlen(cidr_mask) + 1)
goto gather_ipaddr;

if (sn_offset == 0)
--
1.9.3

2014-12-09 16:14:28

by Vitaly Kuznetsov

[permalink] [raw]
Subject: [PATCH 4/5] Tools: hv: address compiler warnings for hv_fcopy_daemon.c

This patch addresses two types of compiler warnings:
... warning: unused variable ‘fd’ [-Wunused-variable]
and
... warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘__u16 *’ [-Wformat=]

Signed-off-by: Vitaly Kuznetsov <[email protected]>
---
tools/hv/hv_fcopy_daemon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index f437d73..1a23872 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -51,7 +51,7 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)

p = (char *)smsg->path_name;
snprintf(target_fname, sizeof(target_fname), "%s/%s",
- (char *)smsg->path_name, smsg->file_name);
+ (char *)smsg->path_name, (char *)smsg->file_name);

syslog(LOG_INFO, "Target file name: %s", target_fname);
/*
@@ -137,7 +137,7 @@ void print_usage(char *argv[])

int main(int argc, char *argv[])
{
- int fd, fcopy_fd, len;
+ int fcopy_fd, len;
int error;
int daemonize = 1, long_index = 0, opt;
int version = FCOPY_CURRENT_VERSION;
--
1.9.3

2014-12-10 02:59:21

by Dexuan Cui

[permalink] [raw]
Subject: RE: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup

> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:[email protected]]
> Sent: Tuesday, December 9, 2014 23:48 PM
> To: KY Srinivasan
> Cc: Haiyang Zhang; [email protected]; linux-
> [email protected]; Dexuan Cui
> Subject: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup
>
> When someone does 'make' in tools/hv/ issues appear:
> - hv_fcopy_daemon is not being built;
> - lots of compiler warnings.
>
> This is just a cleanup. Compile-tested by myself on top of linux-next/master.
>
> Piggyback this series and send "[PATCH 5/5] Tools: hv: do not add redundant
> '/'
> in hv_start_fcopy()"
>
> Vitaly Kuznetsov (5):
> Tools: hv: add mising fcopyd to the Makefile
> Tools: hv: remove unused bytes_written from kvp_update_file()
> Tools: hv: address compiler warnings for hv_kvp_daemon.c
> Tools: hv: address compiler warnings for hv_fcopy_daemon.c
> Tools: hv: do not add redundant '/' in hv_start_fcopy()
>
> tools/hv/Makefile | 4 ++--
> tools/hv/hv_fcopy_daemon.c | 10 ++--------
> tools/hv/hv_kvp_daemon.c | 29 +++++++++++++----------------
> 3 files changed, 17 insertions(+), 26 deletions(-)
>
> --
> 1.9.3

Hi Vitaly,
Thanks for the patchset!

Acked-by: Dexuan Cui <[email protected]>

PS, I added Greg into the TO list.
The hv code in drivers/hv/ and tools/hv/ usually has to go into
Greg's tree first.

-- Dexuan
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-12-10 09:22:53

by Vitaly Kuznetsov

[permalink] [raw]
Subject: Re: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup

Dexuan Cui <[email protected]> writes:

>> -----Original Message-----
>> From: Vitaly Kuznetsov [mailto:[email protected]]
>> Sent: Tuesday, December 9, 2014 23:48 PM
>> To: KY Srinivasan
>> Cc: Haiyang Zhang; [email protected]; linux-
>> [email protected]; Dexuan Cui
>> Subject: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup
>>
>> When someone does 'make' in tools/hv/ issues appear:
>> - hv_fcopy_daemon is not being built;
>> - lots of compiler warnings.
>>
>> This is just a cleanup. Compile-tested by myself on top of linux-next/master.
>>
>> Piggyback this series and send "[PATCH 5/5] Tools: hv: do not add redundant
>> '/'
>> in hv_start_fcopy()"
>>
>> Vitaly Kuznetsov (5):
>> Tools: hv: add mising fcopyd to the Makefile
>> Tools: hv: remove unused bytes_written from kvp_update_file()
>> Tools: hv: address compiler warnings for hv_kvp_daemon.c
>> Tools: hv: address compiler warnings for hv_fcopy_daemon.c
>> Tools: hv: do not add redundant '/' in hv_start_fcopy()
>>
>> tools/hv/Makefile | 4 ++--
>> tools/hv/hv_fcopy_daemon.c | 10 ++--------
>> tools/hv/hv_kvp_daemon.c | 29 +++++++++++++----------------
>> 3 files changed, 17 insertions(+), 26 deletions(-)
>>
>> --
>> 1.9.3
>
> Hi Vitaly,
> Thanks for the patchset!
>
> Acked-by: Dexuan Cui <[email protected]>
>
> PS, I added Greg into the TO list.
> The hv code in drivers/hv/ and tools/hv/ usually has to go into
> Greg's tree first.

Well, I don't mind spamming Greg but he's not on the
scripts/get_maintainer.pl output. In case he's not monitoring the list
for patches by some other tool (patchwork?) a patch adding him to
MAINTAINERS would do the job.

Greg, do you want to become an official Hyper-V maintainer in
MAINTAINERS? I can send a patch then :-)

--
Vitaly

2014-12-10 14:48:33

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup

On Wed, Dec 10, 2014 at 10:22:40AM +0100, Vitaly Kuznetsov wrote:
> Dexuan Cui <[email protected]> writes:
>
> >> -----Original Message-----
> >> From: Vitaly Kuznetsov [mailto:[email protected]]
> >> Sent: Tuesday, December 9, 2014 23:48 PM
> >> To: KY Srinivasan
> >> Cc: Haiyang Zhang; [email protected]; linux-
> >> [email protected]; Dexuan Cui
> >> Subject: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup
> >>
> >> When someone does 'make' in tools/hv/ issues appear:
> >> - hv_fcopy_daemon is not being built;
> >> - lots of compiler warnings.
> >>
> >> This is just a cleanup. Compile-tested by myself on top of linux-next/master.
> >>
> >> Piggyback this series and send "[PATCH 5/5] Tools: hv: do not add redundant
> >> '/'
> >> in hv_start_fcopy()"
> >>
> >> Vitaly Kuznetsov (5):
> >> Tools: hv: add mising fcopyd to the Makefile
> >> Tools: hv: remove unused bytes_written from kvp_update_file()
> >> Tools: hv: address compiler warnings for hv_kvp_daemon.c
> >> Tools: hv: address compiler warnings for hv_fcopy_daemon.c
> >> Tools: hv: do not add redundant '/' in hv_start_fcopy()
> >>
> >> tools/hv/Makefile | 4 ++--
> >> tools/hv/hv_fcopy_daemon.c | 10 ++--------
> >> tools/hv/hv_kvp_daemon.c | 29 +++++++++++++----------------
> >> 3 files changed, 17 insertions(+), 26 deletions(-)
> >>
> >> --
> >> 1.9.3
> >
> > Hi Vitaly,
> > Thanks for the patchset!
> >
> > Acked-by: Dexuan Cui <[email protected]>
> >
> > PS, I added Greg into the TO list.
> > The hv code in drivers/hv/ and tools/hv/ usually has to go into
> > Greg's tree first.
>
> Well, I don't mind spamming Greg but he's not on the
> scripts/get_maintainer.pl output. In case he's not monitoring the list
> for patches by some other tool (patchwork?) a patch adding him to
> MAINTAINERS would do the job.
>
> Greg, do you want to become an official Hyper-V maintainer in
> MAINTAINERS? I can send a patch then :-)

No. It's up to the "real" maintainers to take the patches and then
forward them on to me for inclusion in the kernel tree. KY knows
this...

thanks,

greg k-h

2014-12-10 17:50:34

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup



> -----Original Message-----
> From: devel [mailto:[email protected]] On
> Behalf Of [email protected]
> Sent: Wednesday, December 10, 2014 6:48 AM
> To: Vitaly Kuznetsov
> Cc: [email protected]; Haiyang Zhang; linux-
> [email protected]
> Subject: Re: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor
> cleanup
>
> On Wed, Dec 10, 2014 at 10:22:40AM +0100, Vitaly Kuznetsov wrote:
> > Dexuan Cui <[email protected]> writes:
> >
> > >> -----Original Message-----
> > >> From: Vitaly Kuznetsov [mailto:[email protected]]
> > >> Sent: Tuesday, December 9, 2014 23:48 PM
> > >> To: KY Srinivasan
> > >> Cc: Haiyang Zhang; [email protected]; linux-
> > >> [email protected]; Dexuan Cui
> > >> Subject: [PATCH 0/5] Tools: hv: fix compiler warnings and do minor
> > >> cleanup
> > >>
> > >> When someone does 'make' in tools/hv/ issues appear:
> > >> - hv_fcopy_daemon is not being built;
> > >> - lots of compiler warnings.
> > >>
> > >> This is just a cleanup. Compile-tested by myself on top of linux-
> next/master.
> > >>
> > >> Piggyback this series and send "[PATCH 5/5] Tools: hv: do not add
> > >> redundant '/'
> > >> in hv_start_fcopy()"
> > >>
> > >> Vitaly Kuznetsov (5):
> > >> Tools: hv: add mising fcopyd to the Makefile
> > >> Tools: hv: remove unused bytes_written from kvp_update_file()
> > >> Tools: hv: address compiler warnings for hv_kvp_daemon.c
> > >> Tools: hv: address compiler warnings for hv_fcopy_daemon.c
> > >> Tools: hv: do not add redundant '/' in hv_start_fcopy()
> > >>
> > >> tools/hv/Makefile | 4 ++--
> > >> tools/hv/hv_fcopy_daemon.c | 10 ++--------
> > >> tools/hv/hv_kvp_daemon.c | 29 +++++++++++++----------------
> > >> 3 files changed, 17 insertions(+), 26 deletions(-)
> > >>
> > >> --
> > >> 1.9.3
> > >
> > > Hi Vitaly,
> > > Thanks for the patchset!
> > >
> > > Acked-by: Dexuan Cui <[email protected]>
> > >
> > > PS, I added Greg into the TO list.
> > > The hv code in drivers/hv/ and tools/hv/ usually has to go into
> > > Greg's tree first.
> >
> > Well, I don't mind spamming Greg but he's not on the
> > scripts/get_maintainer.pl output. In case he's not monitoring the list
> > for patches by some other tool (patchwork?) a patch adding him to
> > MAINTAINERS would do the job.
> >
> > Greg, do you want to become an official Hyper-V maintainer in
> > MAINTAINERS? I can send a patch then :-)
>
> No. It's up to the "real" maintainers to take the patches and then forward
> them on to me for inclusion in the kernel tree. KY knows this...

I will take care of this.

K. Y
>
> thanks,
>
> greg k-h
> _______________________________________________
> devel mailing list
> [email protected]
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

2014-12-10 18:49:10

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH 2/5] Tools: hv: remove unused bytes_written from kvp_update_file()



> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:[email protected]]
> Sent: Tuesday, December 9, 2014 7:48 AM
> To: KY Srinivasan
> Cc: Haiyang Zhang; [email protected]; linux-
> [email protected]; Dexuan Cui
> Subject: [PATCH 2/5] Tools: hv: remove unused bytes_written from
> kvp_update_file()
>
> fwrite() does not actually return the number of bytes written and this value
> is being ignored anyway and ferror() is being called to check for an error. As
> we assign to this variable and never use it we get the following compile-time
> warning:
> hv_kvp_daemon.c:149:9: warning: variable ‘bytes_written’ set but not used
> [-Wunused-but-set-variable]
>
> Remove bytes_written completely.
>
> Signed-off-by: Vitaly Kuznetsov <[email protected]>
Signed-off-by: K. Y. Srinivasan <[email protected]>
> ---
> tools/hv/hv_kvp_daemon.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index
> 6a6432a..5a274ca 100644
> --- a/tools/hv/hv_kvp_daemon.c
> +++ b/tools/hv/hv_kvp_daemon.c
> @@ -147,7 +147,6 @@ static void kvp_release_lock(int pool) static void
> kvp_update_file(int pool) {
> FILE *filep;
> - size_t bytes_written;
>
> /*
> * We are going to write our in-memory registry out to @@ -163,8
> +162,7 @@ static void kvp_update_file(int pool)
> exit(EXIT_FAILURE);
> }
>
> - bytes_written = fwrite(kvp_file_info[pool].records,
> - sizeof(struct kvp_record),
> + fwrite(kvp_file_info[pool].records, sizeof(struct kvp_record),
> kvp_file_info[pool].num_records, filep);
>
> if (ferror(filep) || fclose(filep)) {
> --
> 1.9.3

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-12-10 18:51:56

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH 3/5] Tools: hv: address compiler warnings for hv_kvp_daemon.c



> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:[email protected]]
> Sent: Tuesday, December 9, 2014 7:48 AM
> To: KY Srinivasan
> Cc: Haiyang Zhang; [email protected]; linux-
> [email protected]; Dexuan Cui
> Subject: [PATCH 3/5] Tools: hv: address compiler warnings for
> hv_kvp_daemon.c
>
> This patch addresses two types of compiler warnings:
> ... warning: comparison between signed and unsigned integer expressions [-
> Wsign-compare] and ... warning: pointer targets in passing argument N of
> ‘kvp_...’ differ in signedness [-Wpointer-sign]
>
> Signed-off-by: Vitaly Kuznetsov <[email protected]>
Signed-off-by: K. Y. Srinivasan <[email protected]>
Thanks Vitaly.

K. Y

> ---
> tools/hv/hv_kvp_daemon.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index
> 5a274ca..48a95f9 100644
> --- a/tools/hv/hv_kvp_daemon.c
> +++ b/tools/hv/hv_kvp_daemon.c
> @@ -308,7 +308,7 @@ static int kvp_file_init(void)
> return 0;
> }
>
> -static int kvp_key_delete(int pool, const char *key, int key_size)
> +static int kvp_key_delete(int pool, const __u8 *key, int key_size)
> {
> int i;
> int j, k;
> @@ -351,8 +351,8 @@ static int kvp_key_delete(int pool, const char *key,
> int key_size)
> return 1;
> }
>
> -static int kvp_key_add_or_modify(int pool, const char *key, int key_size,
> const char *value,
> - int value_size)
> +static int kvp_key_add_or_modify(int pool, const __u8 *key, int key_size,
> + const __u8 *value, int value_size)
> {
> int i;
> int num_records;
> @@ -405,7 +405,7 @@ static int kvp_key_add_or_modify(int pool, const char
> *key, int key_size, const
> return 0;
> }
>
> -static int kvp_get_value(int pool, const char *key, int key_size, char *value,
> +static int kvp_get_value(int pool, const __u8 *key, int key_size, __u8
> +*value,
> int value_size)
> {
> int i;
> @@ -437,8 +437,8 @@ static int kvp_get_value(int pool, const char *key, int
> key_size, char *value,
> return 1;
> }
>
> -static int kvp_pool_enumerate(int pool, int index, char *key, int key_size,
> - char *value, int value_size)
> +static int kvp_pool_enumerate(int pool, int index, __u8 *key, int key_size,
> + __u8 *value, int value_size)
> {
> struct kvp_record *record;
>
> @@ -659,7 +659,7 @@ static char *kvp_if_name_to_mac(char *if_name)
> char *p, *x;
> char buf[256];
> char addr_file[256];
> - int i;
> + unsigned int i;
> char *mac_addr = NULL;
>
> snprintf(addr_file, sizeof(addr_file), "%s%s%s", "/sys/class/net/",
> @@ -698,7 +698,7 @@ static char *kvp_mac_to_if_name(char *mac)
> char buf[256];
> char *kvp_net_dir = "/sys/class/net/";
> char dev_id[256];
> - int i;
> + unsigned int i;
>
> dir = opendir(kvp_net_dir);
> if (dir == NULL)
> @@ -748,7 +748,7 @@ static char *kvp_mac_to_if_name(char *mac)
>
>
> static void kvp_process_ipconfig_file(char *cmd,
> - char *config_buf, int len,
> + char *config_buf, unsigned int len,
> int element_size, int offset)
> {
> char buf[256];
> @@ -766,7 +766,7 @@ static void kvp_process_ipconfig_file(char *cmd,
> if (offset == 0)
> memset(config_buf, 0, len);
> while ((p = fgets(buf, sizeof(buf), file)) != NULL) {
> - if ((len - strlen(config_buf)) < (element_size + 1))
> + if (len < strlen(config_buf) + element_size + 1)
> break;
>
> x = strchr(p, '\n');
> @@ -914,7 +914,7 @@ static int kvp_process_ip_address(void *addrp,
>
> static int
> kvp_get_ip_info(int family, char *if_name, int op,
> - void *out_buffer, int length)
> + void *out_buffer, unsigned int length)
> {
> struct ifaddrs *ifap;
> struct ifaddrs *curp;
> @@ -1017,8 +1017,7 @@ kvp_get_ip_info(int family, char *if_name, int op,
> weight += hweight32(&w[i]);
>
> sprintf(cidr_mask, "/%d", weight);
> - if ((length - sn_offset) <
> - (strlen(cidr_mask) + 1))
> + if (length < sn_offset + strlen(cidr_mask) + 1)
> goto gather_ipaddr;
>
> if (sn_offset == 0)
> --
> 1.9.3

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-12-10 18:52:32

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH 1/5] Tools: hv: add mising fcopyd to the Makefile



> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:[email protected]]
> Sent: Tuesday, December 9, 2014 7:48 AM
> To: KY Srinivasan
> Cc: Haiyang Zhang; [email protected]; linux-
> [email protected]; Dexuan Cui
> Subject: [PATCH 1/5] Tools: hv: add mising fcopyd to the Makefile
>
> fcopyd in missing in the Makefile, add it there.
>
> Signed-off-by: Vitaly Kuznetsov <[email protected]>
Signed-off-by: K. Y. Srinivasan <[email protected]>

Thanks!

K. Y

> ---
> tools/hv/Makefile | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/hv/Makefile b/tools/hv/Makefile index bd22f78..99ffe61
> 100644
> --- a/tools/hv/Makefile
> +++ b/tools/hv/Makefile
> @@ -5,9 +5,9 @@ PTHREAD_LIBS = -lpthread WARNINGS = -Wall -Wextra
> CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS)
>
> -all: hv_kvp_daemon hv_vss_daemon
> +all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
> %: %.c
> $(CC) $(CFLAGS) -o $@ $^
>
> clean:
> - $(RM) hv_kvp_daemon hv_vss_daemon
> + $(RM) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
> --
> 1.9.3

2014-12-10 18:54:24

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH 5/5] Tools: hv: do not add redundant '/' in hv_start_fcopy()



> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:[email protected]]
> Sent: Tuesday, December 9, 2014 7:48 AM
> To: KY Srinivasan
> Cc: Haiyang Zhang; [email protected]; linux-
> [email protected]; Dexuan Cui
> Subject: [PATCH 5/5] Tools: hv: do not add redundant '/' in hv_start_fcopy()
>
> We don't need to add additional '/' to smsg->path_name as
> snprintf("%s/%s") does the right thing. Without the patch we get doubled '//'
> in the log message.
>
> Signed-off-by: Vitaly Kuznetsov <[email protected]>

Signed-off-by: K. Y. Srinivasan <[email protected]>

Thank you.

K. Y
> ---
> tools/hv/hv_fcopy_daemon.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
> index 1a23872..9445d8f 100644
> --- a/tools/hv/hv_fcopy_daemon.c
> +++ b/tools/hv/hv_fcopy_daemon.c
> @@ -43,12 +43,6 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
> int error = HV_E_FAIL;
> char *q, *p;
>
> - /*
> - * If possile append a path seperator to the path.
> - */
> - if (strlen((char *)smsg->path_name) < (W_MAX_PATH - 2))
> - strcat((char *)smsg->path_name, "/");
> -
> p = (char *)smsg->path_name;
> snprintf(target_fname, sizeof(target_fname), "%s/%s",
> (char *)smsg->path_name, (char *)smsg->file_name);
> --
> 1.9.3

2014-12-10 18:55:17

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH 4/5] Tools: hv: address compiler warnings for hv_fcopy_daemon.c



> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:[email protected]]
> Sent: Tuesday, December 9, 2014 7:48 AM
> To: KY Srinivasan
> Cc: Haiyang Zhang; [email protected]; linux-
> [email protected]; Dexuan Cui
> Subject: [PATCH 4/5] Tools: hv: address compiler warnings for
> hv_fcopy_daemon.c
>
> This patch addresses two types of compiler warnings:
> ... warning: unused variable ‘fd’ [-Wunused-variable] and ... warning: format
> ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘__u16 *’ [-
> Wformat=]
>
> Signed-off-by: Vitaly Kuznetsov <[email protected]>

Signed-off-by: K. Y. Srinivasan <[email protected]>
> ---
> tools/hv/hv_fcopy_daemon.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
> index f437d73..1a23872 100644
> --- a/tools/hv/hv_fcopy_daemon.c
> +++ b/tools/hv/hv_fcopy_daemon.c
> @@ -51,7 +51,7 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
>
> p = (char *)smsg->path_name;
> snprintf(target_fname, sizeof(target_fname), "%s/%s",
> - (char *)smsg->path_name, smsg->file_name);
> + (char *)smsg->path_name, (char *)smsg->file_name);
>
> syslog(LOG_INFO, "Target file name: %s", target_fname);
> /*
> @@ -137,7 +137,7 @@ void print_usage(char *argv[])
>
> int main(int argc, char *argv[])
> {
> - int fd, fcopy_fd, len;
> + int fcopy_fd, len;
> int error;
> int daemonize = 1, long_index = 0, opt;
> int version = FCOPY_CURRENT_VERSION;
> --
> 1.9.3

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?