summaryrefslogtreecommitdiffstats
path: root/pcilib
diff options
context:
space:
mode:
authornicolas.zilio@hotmail.fr <>2015-09-15 19:25:47 +0200
committernicolas.zilio@hotmail.fr <>2015-09-15 19:25:47 +0200
commit16556c4b24e37a4d451b7a85a5d260c4ee9828cb (patch)
tree542b3e110aa2d7883f5d5c4ab62ddbaa1e145d05 /pcilib
parente43b676d8294f37410ea0fa1f9fa39d10df64408 (diff)
downloadpcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.tar.gz
pcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.tar.bz2
pcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.tar.xz
pcitool-16556c4b24e37a4d451b7a85a5d260c4ee9828cb.zip
no more realloc in op enum
Diffstat (limited to 'pcilib')
-rw-r--r--pcilib/views.c9
1 files changed, 6 insertions, 3 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_size<strlen(((pcilib_enum_t*)(params))[j].name)){
+ pcilib_error("the string to contain the enum command is too tight");
+ return PCILIB_ERROR_MEMORY;
+ }
strncpy(name,((pcilib_enum_t*)(params))[j].name, strlen(((pcilib_enum_t*)(params))[j].name));
k=strlen(((pcilib_enum_t*)(params))[j].name);
name[k]='\0';