Only the first really needs fixing, but while we're looking at this code...
There's corresponding code in MirSocketRpcChannel::receive_file_descriptors() that also uses "sizeof(struct cmsghdr) + sizeof(int) * n_fds" - the fix should be applied uniformly.
~~~~
77 + int i = 0;
78 + for (auto &fd: fds)
79 + data[i++] = fd;
I guess it is pre-existing, but what's wrong with using std::copy?
std::copy(fds.begin(), fds.end(), data);
~~~~
It is inefficiency rather than a bug, but we're copying a std::vector into the lambda simply to make it available as a data source for further copying.
Only the first really needs fixing, but while we're looking at this code...
There's corresponding code in MirSocketRpcCha nnel::receive_ file_descriptor s() that also uses "sizeof(struct cmsghdr) + sizeof(int) * n_fds" - the fix should be applied uniformly.
~~~~
77 + int i = 0;
78 + for (auto &fd: fds)
79 + data[i++] = fd;
I guess it is pre-existing, but what's wrong with using std::copy?
std::copy( fds.begin( ), fds.end(), data);
~~~~
It is inefficiency rather than a bug, but we're copying a std::vector into the lambda simply to make it available as a data source for further copying.