On Thu, Dec 05, 2019 at 07:27:06PM +0800, Anand Jain wrote:
> +static void btrfs_dev_state_to_str(struct btrfs_device *device, char *dev_state_str, size_t n)
> +{
> + int state;
> + const char *btrfs_dev_states[] = { "WRITEABLE", "IN_FS_METADATA",
> + "MISSING", "REPLACE_TGT", "FLUSHING"
> + };
> +
> + n = n - strlen(dev_state_str) - 1;
> +
> + for (state = 0; state < ARRAY_SIZE(btrfs_dev_states); state++) {
> + if (test_bit(state, &device->dev_state)) {
> + if (strlen(dev_state_str))
> + strncat(dev_state_str, " ", n);
> + strncat(dev_state_str, btrfs_dev_states[state], n);
> + }
> + }
> + strncat(dev_state_str, "\n", n);
Please use the snprintf way as in supported_checksums_show and not the
str* functions.