Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2021-11-26 21:09:41 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2021-11-26 21:12:18 +0300
commit426a60efaf6a2fa0183875d2f31aefe98575306f (patch)
tree83e0f8d8acaa9a5ee2901208f8631780155444bf /pb_encode.c
parentab19ecbe1b9f377ab4ee8e762bfe16c39068ad68 (diff)
Fix compiler warning with PB_BUFFER_ONLY (#717)
I also took the opportunity to get rid of a potential undefined behavior. Now the marker value used is a valid const int pointer.
Diffstat (limited to 'pb_encode.c')
-rw-r--r--pb_encode.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pb_encode.c b/pb_encode.c
index f5f1676..2ad9925 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -65,7 +65,11 @@ pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
{
pb_ostream_t stream;
#ifdef PB_BUFFER_ONLY
- stream.callback = (void*)1; /* Just a marker value */
+ /* In PB_BUFFER_ONLY configuration the callback pointer is just int*.
+ * NULL pointer marks a sizing field, so put a non-NULL value to mark a buffer stream.
+ */
+ static const int marker;
+ stream.callback = &marker;
#else
stream.callback = &buf_write;
#endif