C API: Some boolean options do not use unsigned char
- Dominant language
- C++
- Stars
- 32.1k
- Forks
- 6.9k
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Description
I am developing Kotlin/Native bindings for RocksDB using the C API. I have found that some functions relating to boolean configuration properties in `c.h` do not match the documentation
### Expected behavior
I expect that functions that set/get boolean properties use the `unsigned char` to represent boolean
> Bools have the type unsigned char (0 == false; rest == true)
https://github.com/facebook/rocksdb/blob/0a2d3b663a962cf86af5ad82c80baf1cd71f7766/include/rocksdb/c.h#L40
### Actual behavior
I observe that the set/get types of some properties do not match.
For example, `disable_auto_compactions`
https://github.com/facebook/rocksdb/blob/0a2d3b663a962cf86af5ad82c80baf1cd71f7766/include/rocksdb/c.h#L1487-L1490
The name indicates that this should be a boolean property.
* The getter returns `unsigned char` (as expected)
* The setter expects an `int` (which I do not expect)
### Steps to reproduce the behavior
These are the options that I think have mismatched functions
* `report_bg_io_stats`
https://github.com/facebook/rocksdb/blob/0a2d3b663a962cf86af5ad82c80baf1cd71f7766/include/rocksdb/c.h#L1544-L1547
* `disable_auto_compactions`
https://github.com/facebook/rocksdb/blob/0a2d3b663a962cf86af5ad82c80baf1cd71f7766/include/rocksdb/c.h#L1487-L1490
* `optimize_filters_for_hits`
https://github.com/facebook/rocksdb/blob/0a2d3b663a962cf86af5ad82c80baf1cd71f7766/include/rocksdb/c.h#L1491-L1494
Perhaps I have misunderstood the documentation, and these functions are correct. In which case, could the docs be updated to explain the relationship between an `int` and `unsigned char`? Should the same logic of `if (value == 0) false else true` be used?
Contributor guide
Assessment
This issue has not been assessed yet.