You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/02/21 10:56:35 UTC
[GitHub] [mynewt-core] de-nordic opened a new pull request #2200:
cborencoder: Add functions calculating size of encoded data
de-nordic opened a new pull request #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200
The functions will allow to check how much space in encoded stream would
data take, given the value or input size, in case of encoding strings.
Signed-off-by: Dominik Ermel <do...@nordicsemi.no>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] de-nordic commented on issue #2200: cborencoder: Add
functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
de-nordic commented on issue #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200#issuecomment-590349010
@vrahane, thanks I have been able to solve problem with use of count encoder. This PR is no longer needed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] vrahane commented on issue #2200: cborencoder: Add
functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
vrahane commented on issue #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200#issuecomment-589803276
@de-nordic We do have a have a count encoder, which does the same thing.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] de-nordic commented on issue #2200: cborencoder: Add
functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
de-nordic commented on issue #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200#issuecomment-590188153
>
>
> @de-nordic We do have a have a count encoder, which does the same thing.
Thx. Didn't know about it. I will use the count encoder.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] de-nordic closed pull request #2200: cborencoder: Add
functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
de-nordic closed pull request #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2200:
cborencoder: Add functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200#issuecomment-589642651
<!-- style-bot -->
## Style check summary
### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
#### encoding/tinycbor/include/tinycbor/cbor.h
<details>
```diff
@@ -190,32 +190,59 @@
CBOR_API CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value);
CBOR_API CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag);
CBOR_API CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length);
-CBOR_INLINE_API CborError cbor_encode_text_stringz(CborEncoder *encoder, const char *string)
-{ return cbor_encode_text_string(encoder, string, strlen(string)); }
+CBOR_INLINE_API CborError
+cbor_encode_text_stringz(CborEncoder *encoder, const char *string)
+{
+ return cbor_encode_text_string(encoder, string, strlen(string));
+}
CBOR_API CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length);
CBOR_API CborError cbor_encode_byte_iovec(CborEncoder *encoder,
const struct cbor_iovec iov[],
int iov_len);
CBOR_API CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value);
-CBOR_INLINE_API int cbor_encode_bytes_written(CborEncoder *encoder)
-{ return encoder->writer->bytes_written; }
-CBOR_INLINE_API CborError cbor_encode_boolean(CborEncoder *encoder, bool value)
-{ return cbor_encode_simple_value(encoder, (int)value - 1 + (CborBooleanType & 0x1f)); }
-CBOR_INLINE_API CborError cbor_encode_null(CborEncoder *encoder)
-{ return cbor_encode_simple_value(encoder, CborNullType & 0x1f); }
-CBOR_INLINE_API CborError cbor_encode_undefined(CborEncoder *encoder)
-{ return cbor_encode_simple_value(encoder, CborUndefinedType & 0x1f); }
+CBOR_INLINE_API int
+cbor_encode_bytes_written(CborEncoder *encoder)
+{
+ return encoder->writer->bytes_written;
+}
+CBOR_INLINE_API CborError
+cbor_encode_boolean(CborEncoder *encoder, bool value)
+{
+ return cbor_encode_simple_value(encoder, (int)value - 1 + (CborBooleanType & 0x1f));
+}
+CBOR_INLINE_API CborError
+cbor_encode_null(CborEncoder *encoder)
+{
+ return cbor_encode_simple_value(encoder, CborNullType & 0x1f);
+}
+CBOR_INLINE_API CborError
+cbor_encode_undefined(CborEncoder *encoder)
+{
+ return cbor_encode_simple_value(encoder, CborUndefinedType & 0x1f);
+}
CBOR_API size_t cbor_encode_int_get_size(uint64_t ui);
-CBOR_INLINE_API size_t cbor_encode_string_get_size(size_t s)
-{ return cbor_encode_int_get_size(s) + s; }
-
-CBOR_INLINE_API CborError cbor_encode_half_float(CborEncoder *encoder, const void *value)
-{ return cbor_encode_floating_point(encoder, CborHalfFloatType, value); }
-CBOR_INLINE_API CborError cbor_encode_float(CborEncoder *encoder, float value)
-{ return cbor_encode_floating_point(encoder, CborFloatType, &value); }
-CBOR_INLINE_API CborError cbor_encode_double(CborEncoder *encoder, double value)
-{ return cbor_encode_floating_point(encoder, CborDoubleType, &value); }
+CBOR_INLINE_API size_t
+cbor_encode_string_get_size(size_t s)
+{
+ return cbor_encode_int_get_size(s) + s;
+}
+
+CBOR_INLINE_API CborError
+cbor_encode_half_float(CborEncoder *encoder, const void *value)
+{
+ return cbor_encode_floating_point(encoder, CborHalfFloatType, value);
+}
+CBOR_INLINE_API CborError
+cbor_encode_float(CborEncoder *encoder, float value)
+{
+ return cbor_encode_floating_point(encoder, CborFloatType, &value);
+}
+CBOR_INLINE_API CborError
+cbor_encode_double(CborEncoder *encoder, double value)
+{
+ return cbor_encode_floating_point(encoder, CborDoubleType, &value);
+}
CBOR_API CborError cbor_encoder_create_array(CborEncoder *encoder, CborEncoder *arrayEncoder, size_t length);
CBOR_API CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *mapEncoder, size_t length);
```
</details>
#### encoding/tinycbor/src/cborencoder.c
<details>
```diff
@@ -391,7 +413,8 @@
* Returns size in bytes it will take to encode \a ui.
*
*/
-size_t cbor_encode_int_get_size(uint64_t ui)
+size_t
+cbor_encode_int_get_size(uint64_t ui)
{
size_t s = 1;
```
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2200:
cborencoder: Add functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200#issuecomment-589622694
<!-- style-bot -->
## Style check summary
### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
#### encoding/tinycbor/include/tinycbor/cbor.h
<details>
```diff
@@ -190,32 +190,59 @@
CBOR_API CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value);
CBOR_API CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag);
CBOR_API CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length);
-CBOR_INLINE_API CborError cbor_encode_text_stringz(CborEncoder *encoder, const char *string)
-{ return cbor_encode_text_string(encoder, string, strlen(string)); }
+CBOR_INLINE_API CborError
+cbor_encode_text_stringz(CborEncoder *encoder, const char *string)
+{
+ return cbor_encode_text_string(encoder, string, strlen(string));
+}
CBOR_API CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length);
CBOR_API CborError cbor_encode_byte_iovec(CborEncoder *encoder,
const struct cbor_iovec iov[],
int iov_len);
CBOR_API CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value);
-CBOR_INLINE_API int cbor_encode_bytes_written(CborEncoder *encoder)
-{ return encoder->writer->bytes_written; }
-CBOR_INLINE_API CborError cbor_encode_boolean(CborEncoder *encoder, bool value)
-{ return cbor_encode_simple_value(encoder, (int)value - 1 + (CborBooleanType & 0x1f)); }
-CBOR_INLINE_API CborError cbor_encode_null(CborEncoder *encoder)
-{ return cbor_encode_simple_value(encoder, CborNullType & 0x1f); }
-CBOR_INLINE_API CborError cbor_encode_undefined(CborEncoder *encoder)
-{ return cbor_encode_simple_value(encoder, CborUndefinedType & 0x1f); }
+CBOR_INLINE_API int
+cbor_encode_bytes_written(CborEncoder *encoder)
+{
+ return encoder->writer->bytes_written;
+}
+CBOR_INLINE_API CborError
+cbor_encode_boolean(CborEncoder *encoder, bool value)
+{
+ return cbor_encode_simple_value(encoder, (int)value - 1 + (CborBooleanType & 0x1f));
+}
+CBOR_INLINE_API CborError
+cbor_encode_null(CborEncoder *encoder)
+{
+ return cbor_encode_simple_value(encoder, CborNullType & 0x1f);
+}
+CBOR_INLINE_API CborError
+cbor_encode_undefined(CborEncoder *encoder)
+{
+ return cbor_encode_simple_value(encoder, CborUndefinedType & 0x1f);
+}
CBOR_API size_t cbor_encode_int_get_size(uint64_t ui);
-CBOR_INLINE_API size_t cbor_encode_string_get_size(size_t s)
-{ return cbor_encode_int_get_size(s) + s; }
-
-CBOR_INLINE_API CborError cbor_encode_half_float(CborEncoder *encoder, const void *value)
-{ return cbor_encode_floating_point(encoder, CborHalfFloatType, value); }
-CBOR_INLINE_API CborError cbor_encode_float(CborEncoder *encoder, float value)
-{ return cbor_encode_floating_point(encoder, CborFloatType, &value); }
-CBOR_INLINE_API CborError cbor_encode_double(CborEncoder *encoder, double value)
-{ return cbor_encode_floating_point(encoder, CborDoubleType, &value); }
+CBOR_INLINE_API size_t
+cbor_encode_string_get_size(size_t s)
+{
+ return cbor_encode_int_get_size(s) + s;
+}
+
+CBOR_INLINE_API CborError
+cbor_encode_half_float(CborEncoder *encoder, const void *value)
+{
+ return cbor_encode_floating_point(encoder, CborHalfFloatType, value);
+}
+CBOR_INLINE_API CborError
+cbor_encode_float(CborEncoder *encoder, float value)
+{
+ return cbor_encode_floating_point(encoder, CborFloatType, &value);
+}
+CBOR_INLINE_API CborError
+cbor_encode_double(CborEncoder *encoder, double value)
+{
+ return cbor_encode_floating_point(encoder, CborDoubleType, &value);
+}
CBOR_API CborError cbor_encoder_create_array(CborEncoder *encoder, CborEncoder *arrayEncoder, size_t length);
CBOR_API CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *mapEncoder, size_t length);
```
</details>
#### encoding/tinycbor/src/cborencoder.c
<details>
```diff
@@ -391,24 +413,25 @@
* Returns size in bytes it will take to encode \a ui.
*
*/
-size_t cbor_encode_int_get_size(uint64_t ui)
-{
- size_t s = 1;
-
- if (ui >= Value8Bit) {
- s += 1;
- if (ui > 0xffU) {
- s += 1;
- }
- if (ui > 0xffffU) {
- s += 2;
- }
- if (ui > 0xffffffffU) {
- s += 4;
- }
- }
-
- return s;
+size_t
+cbor_encode_int_get_size(uint64_t ui)
+{
+ size_t s = 1;
+
+ if (ui >= Value8Bit) {
+ s += 1;
+ if (ui > 0xffU) {
+ s += 1;
+ }
+ if (ui > 0xffffU) {
+ s += 2;
+ }
+ if (ui > 0xffffffffU) {
+ s += 4;
+ }
+ }
+
+ return s;
}
```
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] de-nordic commented on issue #2200: cborencoder: Add
functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
de-nordic commented on issue #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200#issuecomment-589612031
@mlaz please notify whoever there is needed to review this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2200:
cborencoder: Add functions calculating size of encoded data
Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #2200: cborencoder: Add functions calculating size of encoded data
URL: https://github.com/apache/mynewt-core/pull/2200#issuecomment-589622694
<!-- style-bot -->
## Style check summary
### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
#### encoding/tinycbor/include/tinycbor/cbor.h
<details>
```diff
@@ -190,32 +190,59 @@
CBOR_API CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value);
CBOR_API CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag);
CBOR_API CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length);
-CBOR_INLINE_API CborError cbor_encode_text_stringz(CborEncoder *encoder, const char *string)
-{ return cbor_encode_text_string(encoder, string, strlen(string)); }
+CBOR_INLINE_API CborError
+cbor_encode_text_stringz(CborEncoder *encoder, const char *string)
+{
+ return cbor_encode_text_string(encoder, string, strlen(string));
+}
CBOR_API CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length);
CBOR_API CborError cbor_encode_byte_iovec(CborEncoder *encoder,
const struct cbor_iovec iov[],
int iov_len);
CBOR_API CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value);
-CBOR_INLINE_API int cbor_encode_bytes_written(CborEncoder *encoder)
-{ return encoder->writer->bytes_written; }
-CBOR_INLINE_API CborError cbor_encode_boolean(CborEncoder *encoder, bool value)
-{ return cbor_encode_simple_value(encoder, (int)value - 1 + (CborBooleanType & 0x1f)); }
-CBOR_INLINE_API CborError cbor_encode_null(CborEncoder *encoder)
-{ return cbor_encode_simple_value(encoder, CborNullType & 0x1f); }
-CBOR_INLINE_API CborError cbor_encode_undefined(CborEncoder *encoder)
-{ return cbor_encode_simple_value(encoder, CborUndefinedType & 0x1f); }
+CBOR_INLINE_API int
+cbor_encode_bytes_written(CborEncoder *encoder)
+{
+ return encoder->writer->bytes_written;
+}
+CBOR_INLINE_API CborError
+cbor_encode_boolean(CborEncoder *encoder, bool value)
+{
+ return cbor_encode_simple_value(encoder, (int)value - 1 + (CborBooleanType & 0x1f));
+}
+CBOR_INLINE_API CborError
+cbor_encode_null(CborEncoder *encoder)
+{
+ return cbor_encode_simple_value(encoder, CborNullType & 0x1f);
+}
+CBOR_INLINE_API CborError
+cbor_encode_undefined(CborEncoder *encoder)
+{
+ return cbor_encode_simple_value(encoder, CborUndefinedType & 0x1f);
+}
CBOR_API size_t cbor_encode_int_get_size(uint64_t ui);
-CBOR_INLINE_API size_t cbor_encode_string_get_size(size_t s)
-{ return cbor_encode_int_get_size(s) + s; }
-
-CBOR_INLINE_API CborError cbor_encode_half_float(CborEncoder *encoder, const void *value)
-{ return cbor_encode_floating_point(encoder, CborHalfFloatType, value); }
-CBOR_INLINE_API CborError cbor_encode_float(CborEncoder *encoder, float value)
-{ return cbor_encode_floating_point(encoder, CborFloatType, &value); }
-CBOR_INLINE_API CborError cbor_encode_double(CborEncoder *encoder, double value)
-{ return cbor_encode_floating_point(encoder, CborDoubleType, &value); }
+CBOR_INLINE_API size_t
+cbor_encode_string_get_size(size_t s)
+{
+ return cbor_encode_int_get_size(s) + s;
+}
+
+CBOR_INLINE_API CborError
+cbor_encode_half_float(CborEncoder *encoder, const void *value)
+{
+ return cbor_encode_floating_point(encoder, CborHalfFloatType, value);
+}
+CBOR_INLINE_API CborError
+cbor_encode_float(CborEncoder *encoder, float value)
+{
+ return cbor_encode_floating_point(encoder, CborFloatType, &value);
+}
+CBOR_INLINE_API CborError
+cbor_encode_double(CborEncoder *encoder, double value)
+{
+ return cbor_encode_floating_point(encoder, CborDoubleType, &value);
+}
CBOR_API CborError cbor_encoder_create_array(CborEncoder *encoder, CborEncoder *arrayEncoder, size_t length);
CBOR_API CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *mapEncoder, size_t length);
```
</details>
#### encoding/tinycbor/src/cborencoder.c
<details>
```diff
@@ -391,24 +413,25 @@
* Returns size in bytes it will take to encode \a ui.
*
*/
-size_t cbor_encode_int_get_size(uint64_t ui)
-{
- size_t s = 1;
-
- if (ui >= Value8Bit) {
- s += 1;
- if (ui > 0xffU) {
- s += 1;
- }
- if (ui > 0xffffU) {
- s += 2;
- }
- if (ui > 0xffffffffU) {
- s += 4;
- }
- }
-
- return s;
+size_t
+cbor_encode_int_get_size(uint64_t ui)
+{
+ size_t s = 1;
+
+ if (ui >= Value8Bit) {
+ s += 1;
+ if (ui > 0xffU) {
+ s += 1;
+ }
+ if (ui > 0xffffU) {
+ s += 2;
+ }
+ if (ui > 0xffffffffU) {
+ s += 4;
+ }
+ }
+
+ return s;
}
```
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services