Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
4455858c
Commit
4455858c
authored
Oct 10, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: factorize some error messages
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
d1f43bb1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
26 deletions
+17
-26
conf.c
lib/conf.c
+17
-26
No files found.
lib/conf.c
View file @
4455858c
...
...
@@ -34,12 +34,20 @@ static int f_port(int lineno, int iarg, char *sarg)
return
0
;
}
#define CHECK_PPI(need)
/* Quick hack to factorize errors later */
\
({if (need && !current_ppi) { \
pp_printf("config line %i: no port for this config\n", lineno);\
return -1; \
} \
if (!need && current_ppi) { \
pp_printf("config line %i: global config under \"port\"\n", \
lineno); \
return -1; \
}})
static
int
f_if
(
int
lineno
,
int
iarg
,
char
*
sarg
)
{
if
(
!
current_ppi
)
{
pp_printf
(
"config line %i: no port for this config
\n
"
,
lineno
);
return
-
1
;
}
CHECK_PPI
(
1
);
strcpy
(
current_ppi
->
cfg
.
iface_name
,
sarg
);
return
0
;
}
...
...
@@ -47,30 +55,21 @@ static int f_if(int lineno, int iarg, char *sarg)
/* The following ones are so similar. Bah... set a pointer somewhere? */
static
int
f_proto
(
int
lineno
,
int
iarg
,
char
*
sarg
)
{
if
(
!
current_ppi
)
{
pp_printf
(
"config line %i: no port for this config
\n
"
,
lineno
);
return
-
1
;
}
CHECK_PPI
(
1
);
current_ppi
->
cfg
.
proto
=
iarg
;
return
0
;
}
static
int
f_role
(
int
lineno
,
int
iarg
,
char
*
sarg
)
{
if
(
!
current_ppi
)
{
pp_printf
(
"config line %i: no port for this config
\n
"
,
lineno
);
return
-
1
;
}
CHECK_PPI
(
1
);
current_ppi
->
cfg
.
role
=
iarg
;
return
0
;
}
static
int
f_ext
(
int
lineno
,
int
iarg
,
char
*
sarg
)
{
if
(
!
current_ppi
)
{
pp_printf
(
"config line %i: no port for this config
\n
"
,
lineno
);
return
-
1
;
}
CHECK_PPI
(
1
);
current_ppi
->
cfg
.
ext
=
iarg
;
return
0
;
}
...
...
@@ -78,22 +77,14 @@ static int f_ext(int lineno, int iarg, char *sarg)
/* The following two are identical as well. I really need a pointer... */
static
int
f_class
(
int
lineno
,
int
iarg
,
char
*
sarg
)
{
if
(
current_ppi
)
{
pp_printf
(
"config line %i: global config under
\"
port
\"\n
"
,
lineno
);
return
-
1
;
}
CHECK_PPI
(
0
);
GOPTS
(
current_ppg
)
->
clock_quality
.
clockClass
=
iarg
;
return
0
;
}
static
int
f_accuracy
(
int
lineno
,
int
iarg
,
char
*
sarg
)
{
if
(
current_ppi
)
{
pp_printf
(
"config line %i: global config under
\"
port
\"\n
"
,
lineno
);
return
-
1
;
}
CHECK_PPI
(
0
);
GOPTS
(
current_ppg
)
->
clock_quality
.
clockAccuracy
=
iarg
;
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment