diff options
author | nicolas.zilio@hotmail.fr <> | 2015-09-15 19:25:47 +0200 |
---|---|---|
committer | nicolas.zilio@hotmail.fr <> | 2015-09-15 19:25:47 +0200 |
commit | 16556c4b24e37a4d451b7a85a5d260c4ee9828cb (patch) | |
tree | 542b3e110aa2d7883f5d5c4ab62ddbaa1e145d05 /pcitool/cli.c | |
parent | e43b676d8294f37410ea0fa1f9fa39d10df64408 (diff) | |
download | pcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.tar.gz pcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.tar.bz2 pcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.tar.xz pcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.zip |
no more realloc in op enum
Diffstat (limited to 'pcitool/cli.c')
-rw-r--r-- | pcitool/cli.c | 14 |
1 files changed, 5 insertions, 9 deletions
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{ |