diff mbox

[1/3] ndctl: fix return value truncation for ndctl_cmd_ars_get_record_{addr, len}

Message ID 20151110111704.15310.17901.stgit@dwillia2-desk3.jf.intel.com (mailing list archive)
State Accepted
Commit 22e7a77dc4ad
Headers show

Commit Message

Dan Williams Nov. 10, 2015, 11:17 a.m. UTC
By inspection noticed that these functions were truncating the command
results for these fields from 8-bytes to 4.

Cc: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl.c       |    8 ++++----
 lib/ndctl/libndctl.h |    4 ++--
 lib/test-libndctl.c  |    4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

Comments

Verma, Vishal L Nov. 10, 2015, 8:21 p.m. UTC | #1
On Tue, 2015-11-10 at 06:17 -0500, Dan Williams wrote:
> By inspection noticed that these functions were truncating the command

> results for these fields from 8-bytes to 4.

> 

> Cc: Vishal Verma <vishal.l.verma@intel.com>

> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

> ---

>  lib/libndctl.c       |    8 ++++----

>  lib/ndctl/libndctl.h |    4 ++--

>  lib/test-libndctl.c  |    4 ++--

>  3 files changed, 8 insertions(+), 8 deletions(-)


Good catch, thanks!

In the commit message, did you mean truncating from 8-bytes to 4 instead
of the other way round?
Apart from that:

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>


> 

> diff --git a/lib/libndctl.c b/lib/libndctl.c

> index 6bfc79f95b83..ea3947dd3e33 100644

> --- a/lib/libndctl.c

> +++ b/lib/libndctl.c

> @@ -1873,8 +1873,8 @@ NDCTL_EXPORT unsigned int

> ndctl_cmd_ars_num_records(struct ndctl_cmd *ars_stat)

>  	return 0;

>  }

>  

> -NDCTL_EXPORT unsigned int ndctl_cmd_ars_get_record_addr(struct

> ndctl_cmd *ars_stat,

> -		unsigned int rec_index)

> +NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_addr(

> +		struct ndctl_cmd *ars_stat, unsigned int rec_index)

>  {

>  	struct ndctl_ctx *ctx =

> ndctl_bus_get_ctx(cmd_to_bus(ars_stat));

>  

> @@ -1890,8 +1890,8 @@ NDCTL_EXPORT unsigned int

> ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_st

>  	return 0;

>  }

>  

> -NDCTL_EXPORT unsigned int ndctl_cmd_ars_get_record_len(struct

> ndctl_cmd *ars_stat,

> -		unsigned int rec_index)

> +NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_len(

> +		struct ndctl_cmd *ars_stat, unsigned int rec_index)

>  {

>  	struct ndctl_ctx *ctx =

> ndctl_bus_get_ctx(cmd_to_bus(ars_stat));

>  

> diff --git a/lib/ndctl/libndctl.h b/lib/ndctl/libndctl.h

> index 1bef168935b0..31118c646520 100644

> --- a/lib/ndctl/libndctl.h

> +++ b/lib/ndctl/libndctl.h

> @@ -156,9 +156,9 @@ struct ndctl_cmd

> *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ars_cap);

>  unsigned int ndctl_cmd_ars_cap_get_size(struct ndctl_cmd *ars_cap);

>  unsigned int ndctl_cmd_ars_in_progress(struct ndctl_cmd *ars_status);

>  unsigned int ndctl_cmd_ars_num_records(struct ndctl_cmd *ars_stat);

> -unsigned int ndctl_cmd_ars_get_record_addr(struct ndctl_cmd

> *ars_stat,

> +unsigned long long ndctl_cmd_ars_get_record_addr(struct ndctl_cmd

> *ars_stat,

>  		unsigned int rec_index);

> -unsigned int ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat,

> +unsigned long long ndctl_cmd_ars_get_record_len(struct ndctl_cmd

> *ars_stat,

>  		unsigned int rec_index);

>  struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(struct

> ndctl_dimm *dimm,

>  		unsigned int opcode, size_t input_size, size_t

> output_size);

> diff --git a/lib/test-libndctl.c b/lib/test-libndctl.c

> index b0221335606e..b51af6b42880 100644

> --- a/lib/test-libndctl.c

> +++ b/lib/test-libndctl.c

> @@ -1351,9 +1351,9 @@ static int check_ars_status(struct ndctl_bus

> *bus, struct ndctl_dimm *dimm,

>  	} while (ndctl_cmd_ars_in_progress(cmd));

>  

>  	for (i = 0; i < ndctl_cmd_ars_num_records(cmd); i++) {

> -		fprintf(stderr, "%s: record[%d].addr: 0x%x\n",

> __func__, i,

> +		fprintf(stderr, "%s: record[%d].addr: 0x%llx\n",

> __func__, i,

>  			ndctl_cmd_ars_get_record_addr(cmd, i));

> -		fprintf(stderr, "%s: record[%d].length: 0x%x\n",

> __func__, i,

> +		fprintf(stderr, "%s: record[%d].length: 0x%llx\n",

> __func__, i,

>  			ndctl_cmd_ars_get_record_len(cmd, i));

>  	}

>  

>
Dan Williams Nov. 10, 2015, 8:30 p.m. UTC | #2
On Tue, Nov 10, 2015 at 12:21 PM, Verma, Vishal L
<vishal.l.verma@intel.com> wrote:
> On Tue, 2015-11-10 at 06:17 -0500, Dan Williams wrote:
>> By inspection noticed that these functions were truncating the command
>> results for these fields from 8-bytes to 4.
>>
>> Cc: Vishal Verma <vishal.l.verma@intel.com>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> ---
>>  lib/libndctl.c       |    8 ++++----
>>  lib/ndctl/libndctl.h |    4 ++--
>>  lib/test-libndctl.c  |    4 ++--
>>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> Good catch, thanks!
>
> In the commit message, did you mean truncating from 8-bytes to 4 instead
> of the other way round?

I had it backwards in the original patch, but fixed in this version.

> Apart from that:
>
> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

Thanks!
diff mbox

Patch

diff --git a/lib/libndctl.c b/lib/libndctl.c
index 6bfc79f95b83..ea3947dd3e33 100644
--- a/lib/libndctl.c
+++ b/lib/libndctl.c
@@ -1873,8 +1873,8 @@  NDCTL_EXPORT unsigned int ndctl_cmd_ars_num_records(struct ndctl_cmd *ars_stat)
 	return 0;
 }
 
-NDCTL_EXPORT unsigned int ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_stat,
-		unsigned int rec_index)
+NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_addr(
+		struct ndctl_cmd *ars_stat, unsigned int rec_index)
 {
 	struct ndctl_ctx *ctx = ndctl_bus_get_ctx(cmd_to_bus(ars_stat));
 
@@ -1890,8 +1890,8 @@  NDCTL_EXPORT unsigned int ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_st
 	return 0;
 }
 
-NDCTL_EXPORT unsigned int ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat,
-		unsigned int rec_index)
+NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_len(
+		struct ndctl_cmd *ars_stat, unsigned int rec_index)
 {
 	struct ndctl_ctx *ctx = ndctl_bus_get_ctx(cmd_to_bus(ars_stat));
 
diff --git a/lib/ndctl/libndctl.h b/lib/ndctl/libndctl.h
index 1bef168935b0..31118c646520 100644
--- a/lib/ndctl/libndctl.h
+++ b/lib/ndctl/libndctl.h
@@ -156,9 +156,9 @@  struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ars_cap);
 unsigned int ndctl_cmd_ars_cap_get_size(struct ndctl_cmd *ars_cap);
 unsigned int ndctl_cmd_ars_in_progress(struct ndctl_cmd *ars_status);
 unsigned int ndctl_cmd_ars_num_records(struct ndctl_cmd *ars_stat);
-unsigned int ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_stat,
+unsigned long long ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_stat,
 		unsigned int rec_index);
-unsigned int ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat,
+unsigned long long ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat,
 		unsigned int rec_index);
 struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(struct ndctl_dimm *dimm,
 		unsigned int opcode, size_t input_size, size_t output_size);
diff --git a/lib/test-libndctl.c b/lib/test-libndctl.c
index b0221335606e..b51af6b42880 100644
--- a/lib/test-libndctl.c
+++ b/lib/test-libndctl.c
@@ -1351,9 +1351,9 @@  static int check_ars_status(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 	} while (ndctl_cmd_ars_in_progress(cmd));
 
 	for (i = 0; i < ndctl_cmd_ars_num_records(cmd); i++) {
-		fprintf(stderr, "%s: record[%d].addr: 0x%x\n", __func__, i,
+		fprintf(stderr, "%s: record[%d].addr: 0x%llx\n", __func__, i,
 			ndctl_cmd_ars_get_record_addr(cmd, i));
-		fprintf(stderr, "%s: record[%d].length: 0x%x\n", __func__, i,
+		fprintf(stderr, "%s: record[%d].length: 0x%llx\n", __func__, i,
 			ndctl_cmd_ars_get_record_len(cmd, i));
 	}