Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
2b31129e
Unverified
Commit
2b31129e
authored
6 years ago
by
Joakim Nohlgård
Committed by
Gaëtan Harter
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
sys/cbor: Fix -Wformat=2 warnings
parent
d04058b5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sys/cbor/cbor.c
+4
-5
4 additions, 5 deletions
sys/cbor/cbor.c
with
4 additions
and
5 deletions
sys/cbor/cbor.c
+
4
−
5
View file @
2b31129e
...
...
@@ -87,6 +87,7 @@
/* Array size */
#define MAX_TIMESTRING_LENGTH (21)
#define TIMESTRING_FORMAT "%Y-%m-%dT%H:%M:%SZ"
#ifndef INFINITY
#define INFINITY (1.0/0.0)
...
...
@@ -767,9 +768,8 @@ size_t cbor_deserialize_date_time(const cbor_stream_t *stream, size_t offset, st
char
buffer
[
21
];
offset
++
;
/* skip tag byte to decode date_time */
size_t
read_bytes
=
cbor_deserialize_unicode_string
(
stream
,
offset
,
buffer
,
sizeof
(
buffer
));
const
char
*
format
=
"%Y-%m-%dT%H:%M:%SZ"
;
if
(
strptime
(
buffer
,
format
,
val
)
==
0
)
{
if
(
strptime
(
buffer
,
TIMESTRING_FORMAT
,
val
)
==
0
)
{
return
0
;
}
...
...
@@ -787,9 +787,8 @@ size_t cbor_serialize_date_time(cbor_stream_t *stream, struct tm *val)
CBOR_ENSURE_SIZE
(
stream
,
MAX_TIMESTRING_LENGTH
+
1
);
/* + 1 tag byte */
char
time_str
[
MAX_TIMESTRING_LENGTH
];
const
char
*
format
=
"%Y-%m-%dT%H:%M:%SZ"
;
if
(
strftime
(
time_str
,
sizeof
(
time_str
),
format
,
val
)
==
0
)
{
/* struct tm to string */
if
(
strftime
(
time_str
,
sizeof
(
time_str
),
TIMESTRING_FORMAT
,
val
)
==
0
)
{
/* struct tm to string */
return
0
;
}
...
...
@@ -1017,7 +1016,7 @@ static size_t cbor_stream_decode_at(cbor_stream_t *stream, size_t offset, int in
char
buf
[
64
];
struct
tm
timeinfo
;
size_t
read_bytes
=
cbor_deserialize_date_time
(
stream
,
offset
,
&
timeinfo
);
strftime
(
buf
,
sizeof
(
buf
),
"%c"
,
&
timeinfo
);
strftime
(
buf
,
sizeof
(
buf
),
TIMESTRING_FORMAT
,
&
timeinfo
);
printf
(
"(tag: %u, date/time string:
\"
%s
\"
)
\n
"
,
tag
,
buf
);
return
read_bytes
;
}
...
...
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