It looks complicated, but it's just because I have helper functions and a lot of return codes and error handling I guess.
Anyway, I changed one of my methods implementation to reflect something similar to yours:
struct iio_device *dev;
struct iio_channel *ch;
dev = iio_context_find_device(ctx, "ad9361-phy");
ch = iio_device_find_channel(dev, "voltage0", false);
iio_channel_attr_write_double(ch, "rf_bandwidth", value);
The above fails, but I tried changing to write attribute to long long rather than double. I'm guessing the decimal in the file mucks up something?
Using iio_channel_attr_write_double(ch, "rf_bandwidth", value), it doesn't work:
Get RX RF bandwidth = 18000000.000000
Set RX RF bandwidth = 9000000.000000
Get RX RF bandwidth = 18000000.000000
Set RX RF bandwidth = 36000000.000000
Using iio_channel_attr_write_longlong(ch, "rf_bandwidth", (long long) value), it works:
Get RX RF bandwidth = 18000000.000000
Set RX RF bandwidth = 9000000.000000
Get RX RF bandwidth = 9000000.000000
Set RX RF bandwidth = 18000000.000000
I made a similar change to my LO set/get methods and it is fixed there now also. This seems like a bug to me, unless you don't intend fractional bandwidth/frequency values?