Skip to content

Commit c2b14fa

Browse files
authored
FSService: Initialise WriteResponse::status on all paths (#2500)
1 parent 92fc208 commit c2b14fa

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎src/components/ble/FSService.cpp‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,17 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
162162
memcpy(filepath, header->pathstr, plen);
163163
filepath[plen] = 0; // Copy and null terminate string
164164
fileSize = header->totalSize;
165-
WriteResponse resp;
165+
WriteResponse resp {};
166166
resp.command = commands::WRITE_PACING;
167167
resp.offset = header->offset;
168168
resp.modTime = 0;
169169

170170
int res = fs.FileOpen(&f, filepath, LFS_O_RDWR | LFS_O_CREAT);
171171
if (res == 0) {
172172
fs.FileClose(&f);
173-
resp.status = (res == 0) ? 0x01 : (int8_t) res;
173+
resp.status = 0x01;
174+
} else {
175+
resp.status = static_cast<int8_t>(res);
174176
}
175177
resp.freespace = std::min(fs.getSize() - (fs.GetFSSize() * fs.getBlockSize()), fileSize - header->offset);
176178
auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(WriteResponse));
@@ -180,9 +182,10 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
180182
case commands::WRITE_DATA: {
181183
NRF_LOG_INFO("[FS_S] -> WriteData");
182184
auto* header = (WritePacing*) om->om_data;
183-
WriteResponse resp;
185+
WriteResponse resp {};
184186
resp.command = commands::WRITE_PACING;
185187
resp.offset = header->offset;
188+
resp.status = 0x01;
186189
int res = 0;
187190

188191
if (!(res = fs.FileOpen(&f, filepath, LFS_O_RDWR | LFS_O_CREAT))) {

0 commit comments

Comments
 (0)