From 16556c4b24e37a4d451b7a85a5d260c4ee9828cb Mon Sep 17 00:00:00 2001 From: "nicolas.zilio@hotmail.fr" <> Date: Tue, 15 Sep 2015 19:25:47 +0200 Subject: no more realloc in op enum --- pcitool/cli.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'pcitool') diff --git a/pcitool/cli.c b/pcitool/cli.c index aa80b72..b168d16 100644 --- a/pcitool/cli.c +++ b/pcitool/cli.c @@ -1047,7 +1047,7 @@ int ReadRegister(pcilib_t *handle, const pcilib_model_description_t *model_info, printf("\n"); } }else if(reg && (s1=strchr(fullreg,'/'))){ - char* enum_command=malloc(sizeof(char*)); + char* enum_command=malloc(50*sizeof(char)); if(!enum_command){ printf("Error allocating memory for the result\n"); return PCILIB_ERROR_MEMORY; @@ -1055,26 +1055,22 @@ int ReadRegister(pcilib_t *handle, const pcilib_model_description_t *model_info, *s1=0; regname=fullreg; viewname=s1+1; - printf("regname %s, viewname %s\n",regname,viewname); if(!strcasecmp(viewname,"name")){ - err = pcilib_read_view(handle,bank,regname,viewname,sizeof(char*),enum_command); + err = pcilib_read_view(handle,bank,regname,viewname,50*sizeof(char),enum_command); if (err) printf("Error reading register %s with an enum view\n", reg); else { printf("%s = %s\n", regname, (char*)enum_command); } free(enum_command); }else{ - pcilib_register_t regid = pcilib_find_register(handle, bank, regname); - bank_id = pcilib_find_register_bank_by_addr(handle, model_info->registers[regid].bank); - format = model_info->banks[bank_id].format; - if (!format) format = "%lu"; + format = "%lf"; err = pcilib_read_view(handle,bank,regname,viewname,sizeof(pcilib_register_value_t),&value); if (err) printf("Error reading register %s with a formula view\n", reg); else { printf("%s = ", reg); printf(format, value); - printf("\n"); + printf("%s\n",viewname); } } } else { @@ -1338,7 +1334,7 @@ int WriteRegister(pcilib_t *handle, const pcilib_model_description_t *model_info if((regname)){ char *view_name; view_name=s1+1;; - err = pcilib_write_view(handle,bank,regname,view_name,sizeof(pcilib_register_value_t),&value); + err = pcilib_write_view(handle,bank,regname,view_name,0,&value); if (err) printf("Error writing register %s using view %s\n",regname,view_name); free(fullregister); }else{ -- cgit v1.2.3