Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
SDB - Self-describing Bus
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
SDB - Self-describing Bus
Commits
94e5ef46
Commit
94e5ef46
authored
Sep 02, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdbfs/userspace: hack around sscanf limitations
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
631ffd1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
gensdbfs.c
sdbfs/userspace/gensdbfs.c
+12
-2
No files found.
sdbfs/userspace/gensdbfs.c
View file @
94e5ef46
...
@@ -166,11 +166,21 @@ static int parse_config_line(struct sdbf *tree, struct sdbf *current, int line,
...
@@ -166,11 +166,21 @@ static int parse_config_line(struct sdbf *tree, struct sdbf *current, int line,
fprintf
(
stderr
,
"parse line %i for %s: %s
\n
"
,
line
,
fprintf
(
stderr
,
"parse line %i for %s: %s
\n
"
,
line
,
current
->
fullname
,
t
);
current
->
fullname
,
t
);
if
(
sscanf
(
t
,
"vendor = %lli"
,
&
int64
)
==
1
)
{
/*
* Unfortunately, scanning as %i refuses "negative" hex values,
* saturating at 0x7fffffff. But %u refuses the leading 0x.
* In order to accept both positive decimal and hex, use %u first,
* and if it returns 0 use %x. I still think hex saturation is a bug.
*/
if
(
sscanf
(
t
,
"vendor = %llu"
,
&
int64
)
==
1
)
{
if
(
int64
==
0
)
sscanf
(
t
,
"vendor = %llx"
,
&
int64
);
p
->
vendor_id
=
htonll
(
int64
);
p
->
vendor_id
=
htonll
(
int64
);
return
0
;
return
0
;
}
}
if
(
sscanf
(
t
,
"device = %li"
,
&
int32
)
==
1
)
{
if
(
sscanf
(
t
,
"device = %lu"
,
&
int32
)
==
1
)
{
if
(
int32
==
0
)
sscanf
(
t
,
"device = %lx"
,
&
int32
);
p
->
device_id
=
htonl
(
int32
);
p
->
device_id
=
htonl
(
int32
);
return
0
;
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