Convert rtems-record-lttng program to C++

Chris Johns chrisj at rtems.org
Mon Sep 2 05:19:48 UTC 2019


On 2/9/19 3:09 pm, Sebastian Huber wrote:
> On 01/09/2019 04:46, Chris Johns wrote:
>> On 31/8/19 5:29 am, Sebastian Huber wrote:
>>> attached are two patches which convert the rtems-record-lttng client program
>>> from C to C++.
>>
>> Is this a step to a full C++ app?
> 
> Yes, it is a step.

Great.

>>
>> The following are some observations about the C++ piece of code...
>>
>> Why in this code ..
>>
>> +
>> +#include <rtems/recordclient.h>
>> +#include <rtems/recorddata.h>
>> +
>> +#include <assert.h>
>> +#include <fcntl.h>
>> +#include <sys/socket.h>
>> +#include <sys/stat.h>
>> +#include <unistd.h>
>> +
>> +#include <arpa/inet.h>
>> +#include <netinet/in.h>
>> +
>> +#include <csignal>
>> +#include <cstring>
>> +
>> +#ifndef RTEMS_TOOLS_TRACE_RECORD_CLIENT_H_
>> +#define RTEMS_TOOLS_TRACE_RECORD_CLIENT_H_
>> +
>>
>> are the includes not protected as well? 
> 
> Hm, this was not intentional. I hope the formatter didn't cause this. I have to
> check that.

Oh!

>> I think the inlines in Client are too
>> big and would be better in a .cc or .cpp file.
> 
> Is it worth doing this? All the code ends up in a main().
> 

Yes, you need to treat C++ is some respect and this is a common trap. If this
was C you would not inline all the code in headers!

>> Why use an assert when you can
>> throw an exception?
> 
> Yes, this is the next step. The client.h is more or less a copy and paste from
> the record-main-lttng.cc.
> 

Great. I am fine with a progression. Sorry I had to ask, it is difficult to tell
from a patch :)

Chris



More information about the devel mailing list