Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
1beed7af
Commit
1beed7af
authored
5 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(config): Always re-read config in case of an error
parent
277a221a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!375
Default main app selector
Pipeline
#4533
canceled
5 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/modules/config.c
+16
-15
16 additions, 15 deletions
epicardium/modules/config.c
with
16 additions
and
15 deletions
epicardium/modules/config.c
+
16
−
15
View file @
1beed7af
...
...
@@ -130,12 +130,12 @@ static void add_config_pair(
static
void
trim
(
char
*
str
)
{
char
*
start
=
str
;
while
(
*
start
&&
!
isgraph
(
(
int
)
*
start
))
while
(
*
start
&&
!
isgraph
(
*
start
))
start
++
;
if
(
strlen
(
start
)
>
0
)
{
char
*
end
=
start
+
strlen
(
start
)
-
1
;
while
(
*
end
&&
!
isgraph
(
(
int
)
*
end
))
while
(
*
end
&&
!
isgraph
(
*
end
))
end
--
;
end
[
1
]
=
0
;
}
...
...
@@ -388,7 +388,6 @@ bool config_get_boolean_with_default(const char *key, bool default_value)
}
}
// TODO: don't allow things like "execute_elf" to be set
int
epic_config_set_string
(
const
char
*
key
,
const
char
*
value_in
)
{
char
value
[
MAX_LINE_LENGTH
+
1
];
...
...
@@ -481,10 +480,10 @@ int epic_config_set_string(const char *key, const char *value_in)
);
}
if
(
write_ret
<
0
)
{
ret
urn
write_ret
;
ret
=
write_ret
;
}
if
(
ret
<
0
)
{
return
re
t
;
goto
ou
t
;
}
if
(
write_ret
<
(
int
)
strlen
(
buf
))
{
LOG_DEBUG
(
...
...
@@ -493,7 +492,8 @@ int epic_config_set_string(const char *key, const char *value_in)
write_ret
,
strlen
(
buf
)
);
return
-
EIO
;
ret
=
-
EIO
;
goto
out
;
}
}
else
{
/* Complex case: The value is already somewhere in the file.
...
...
@@ -511,7 +511,7 @@ int epic_config_set_string(const char *key, const char *value_in)
);
if
(
nread
==
0
)
{
LOG_DEBUG
(
"card10.cfg"
,
"could not read old value"
,
);
goto
out
;
goto
complex_
out
;
}
char
*
end
=
buf
;
...
...
@@ -530,7 +530,7 @@ int epic_config_set_string(const char *key, const char *value_in)
fd1
);
ret
=
fd1
;
goto
out
;
goto
complex_
out
;
}
fd2
=
epic_file_open
(
"card10.nfg"
,
"w"
);
...
...
@@ -542,7 +542,7 @@ int epic_config_set_string(const char *key, const char *value_in)
fd2
);
ret
=
fd2
;
goto
out
;
goto
complex_
out
;
}
/* Copy over slot->value_offset bytes */
...
...
@@ -556,7 +556,7 @@ int epic_config_set_string(const char *key, const char *value_in)
"read failed: rc: %d"
,
ret
);
goto
out
;
goto
complex_
out
;
}
int
ret2
=
epic_file_write
(
fd2
,
buf
,
ret
);
...
...
@@ -568,7 +568,7 @@ int epic_config_set_string(const char *key, const char *value_in)
"write failed: rc: %d"
,
ret
);
goto
out
;
goto
complex_
out
;
}
i
-=
ret
;
}
...
...
@@ -577,7 +577,7 @@ int epic_config_set_string(const char *key, const char *value_in)
ret
=
epic_file_write
(
fd2
,
value
,
strlen
(
value
));
if
(
ret
<
0
)
{
LOG_DEBUG
(
"card10.nfg"
,
"write failed: rc: %d"
,
ret
);
goto
out
;
goto
complex_
out
;
}
/* Skip the old value inside the old file */
...
...
@@ -597,7 +597,7 @@ int epic_config_set_string(const char *key, const char *value_in)
"read failed: rc: %d"
,
ret
);
goto
out
;
goto
complex_
out
;
}
int
ret2
=
epic_file_write
(
fd2
,
buf
,
ret
);
...
...
@@ -609,7 +609,7 @@ int epic_config_set_string(const char *key, const char *value_in)
"write failed: rc: %d"
,
ret
);
goto
out
;
goto
complex_
out
;
}
if
(
ret
<
(
int
)
sizeof
(
buf
))
{
...
...
@@ -617,7 +617,7 @@ int epic_config_set_string(const char *key, const char *value_in)
}
}
out:
complex_
out:
if
(
fd1
>=
0
)
{
epic_file_close
(
fd1
);
}
...
...
@@ -634,6 +634,7 @@ int epic_config_set_string(const char *key, const char *value_in)
}
}
out:
/* Reload config so the new key or the changed value is available */
load_config
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment