On Thu, Jan 23, 2020 at 1:42 PM Marcel Holtmann <marcel@xxxxxxxxxxxx> wrote: > > Hi Alain, > > > I'll separate the simple one liner into a separate patch then will > > wait for your suggestion for the rest. Note that with a single jump > > table as suggested, it will indeed allow us to defunc some op-codes > > pretty easily. > > I have not fully thought this through yet, but here it goes. > > The read_version and read_commands are special since they have to be present no matter what. So on purpose we put these two commands first when we designed the API back in the days. We can special handle them and thus also avoid the forward declaration. I am leaning towards this direction since we might want to actually split commands over multiple files to keep this file readable over time. > > Now the downside with putting the opcode as a field in the data structure is that we actually have to look through the every field until we find the opcode and can not just jump to the position defined by that opcode. That means actually filling the table with NULL pointers for not supported or disable commands might be better. We could still make the read_commands function map the list of supported commands from that table. That may be an acceptable compromise. At least there would be exactly one place to make sure things are aligned. Perhaps we could also leave the op-codes in place and create a test that ensures that if !NULL then op_code == index. > > This will still not fix the list of supported events since that is still static and will require manual patching. Agreed and actually events are less problematic as there is no jump table to fix up. As long as it is in the supported events list, then it works out pretty well, regardless of order... > > Regards > > Marcel >