Building a Tiny CLI Shell for Tiny Firmware | Interrupt

I think there’s a bug in this section:

int cli_cmd_kv_write(int argc, char *argv[]) {
  // We expect 3 arguments:
  // 1. Command name
  // 2. Key
  // 3. Value
  if (argc != 3) {
    shell_put_line("> FAIL,1");
  }

  const char *key = argv[1];
  const char *value = argv[2];

  bool result = kv_store_write(key, value, strlen(value));
  if (!result) {
    shell_put_line("> FAIL,2");
  }
  shell_put_line("> OK");
  return 0;
}

The part that has shell_put_line("> FAIL, 1"); should probably return afterwards otherwise you’ll be accessing past the bounds of the array. The other fail case probably needs to return as afterwards as well, though less serious consequences :slight_smile: