Buffer full when inserting latter value of pair to the map
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- c
調査の方向性
Issue に示されている cbor_encoder_create_map と cbor_encode_byte_string の呼び出しから始め、その後、バッファー満杯エラーが encoder の状態にどのような影響を与えるかを調べてください。値のエンコードに失敗した場合に、対応する値のないキーが map に残るかどうかを確認し、静的に割り当てられたバッファーでサポートされている復旧手順を文書化またはテストしてください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C
- スター
- 634
- フォーク
- 222
- 平均マージ
- 1日 25分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
intel/tinycbor のほかの issue
-
CborValidateTagUse rejects valid tag 1 (epoch) with a floating-point value, and restricts tags 21-23 too much対応中かも @thiagomacieira が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
SteamGridDB/SGDBoop#147 ·
-
Doc: insert executor and incremental consolidation leave sorted runs, not globally sorted headsオープン
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
semantic-reasoning/wirelog#2133 ·
メンテナーはふだん 1 日以内に返信
-
backlog
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
EchoTools/nevr-runtime#454 ·
メンテナーはふだん 1 日以内に返信
-
initramfs: -type f (#18686) skips the libcurl.so.4 symlink, libcurl no longer copied into initramfsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信