Buffer full when inserting latter value of pair to the map
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- c
- Área
- backend-api-design
Línea de trabajo
Comienza con las llamadas a cbor_encoder_create_map y cbor_encode_byte_string mostradas en el issue y, a continuación, inspecciona cómo afectan los errores de búfer lleno al estado del encoder. Determina si un valor fallido deja el map con una clave sin correspondencia y documenta o prueba el procedimiento de recuperación compatible para búferes asignados estáticamente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi!
I have a question which I have not found answer for. Since map contains pairs of items and I understood basically as dictionary (albeit basically same key could occur there multiple times but in my use case not), first value being a key and second one being a value.
So something like:
uint8_t payload[BUFFER_SIZE];
CborEncoder encoder, mapEncoder;
cbor_encoder_init(&encoder, payload, BUFFER_SIZE, 0);
cbor_encoder_create_map(&encoder, &mapEncoder, CborIndefiniteLength); // Don't know in advance how many
...
// Key value pairs are inserted
// until buffer is almost full
...
// Here, inserting key that still fits. Using uint key values for length optimization
// This one succeeds
cbor_encode_uint(&mapEncoder, 0xDEAD);
// Not matter what is the value but something that does not fit. For example string
CborError err = cbor_encode_byte_string(&mapEncoder, "whatever", 8);
What would be the correct procedure to take when writing a key fits to buffer but when writing the value, the buffer is exceeded? We have statically allocated buffer of specific size so it is not possible to reallocate more room.
Currently I'm now evaluating the size of the key+value beforehand and then evaluating whether whole key+value combination is inserted at all. Albeit it works, it feels bit ugly. Instead, if writing of the value fails, the key could be reverted as well (because otherwise when map is closed, last item contains only key and not value). I cannot find any means to do that though.
Any suggestions?
PS Otherwise, this works like a charm and fits to my use case perfectly.
- Lenguaje dominante
- C
- Estrellas
- 641
- Forks
- 222
- Merge medio
- 21 h 33 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de intel/tinycbor
-
CborValidateTagUse rejects valid tag 1 (epoch) with a floating-point value, and restricts tags 21-23 too muchPosiblemente ocupada @thiagomacieira la tomó hace 12 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
CBOR validation not worksAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
Todos los issues de intel/tinycbor
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
FriendsofECCE/ECCE#336 · 1 comentario ·
-
mediatek/filogic: OpenFi 6C (openfi,6c): func key has wrong polarity, event class and key codeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
immortalwrt/immortalwrt#2501 ·
-
Taisei fails to build on BSD because the bundled openlibm is compiled with `-D_ANSI_SOURCE`.Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
taisei-project/taisei#454 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100