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 --- pcilib/views.c | 9 ++++++--- pcitool/cli.c | 14 +++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pcilib/views.c b/pcilib/views.c index 83c5827..2011d86 100644 --- a/pcilib/views.c +++ b/pcilib/views.c @@ -139,7 +139,7 @@ int pcilib_read_view(pcilib_t *ctx, const char *bank, const char *regname, const for(j=0;ctx->register_ctx[i].views[j].name;j++){ if(!(strcasecmp("name",ctx->register_ctx[i].views[j].base_unit.name))){/*if we asked for the unit "name"*/ - err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters,value/*the command name*/,0,&temp_value,0,&(ctx->register_ctx[i].views[j])); + err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters,value/*the command name*/,0,&temp_value,value_size,NULL); if(err){ pcilib_error("can't read from the register with the enum view"); return PCILIB_ERROR_FAILED; @@ -198,7 +198,7 @@ int pcilib_write_view(pcilib_t *ctx, const char *bank, const char *regname, cons ok=1; break; }else if(!(strcasecmp(ctx->register_ctx[i].views[j].base_unit.name,(char*)unit))){/*in this case we asked for then name of the view in unit*/ - temp_value=*(pcilib_register_value_t*)value /*the value to put in the register*/; + //temp_value=*(pcilib_register_value_t*)value /*the value to put in the register*/; err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters, (char*)unit, 1, &temp_value,0,&(ctx->register_ctx[i].views[j])); if(err){ pcilib_error("can't write to the register with the formula view %s", unit); @@ -249,7 +249,10 @@ int operation_enum(pcilib_t *ctx, void *params, char* name, int view2reg, pcilib }else if (view2reg==0){ for(j=0; ((pcilib_enum_t*)(params))[j].name;j++){ if (*regval<=((pcilib_enum_t*)(params))[j].max && *regval>=((pcilib_enum_t*)(params))[j].min){ - name=(char*)realloc(name,strlen(((pcilib_enum_t*)(params))[j].name)*sizeof(char)); + if(viewval_sizeregisters[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