Hi, I think the rule so far have been not to use _get_ (obviously not very strict rule). I'd vote still that we leave _get_ out, since it's so common operation and makes the function names unnecessary long.
E.g. It's obvious (from the function name, args and return value) that the function under returns you the packet length and does nothing else for the packet. size_t odp_packet_len(odp_packet_t pkt) -Petri From: [email protected] [mailto:[email protected]] On Behalf Of ext Ola Liljedahl Sent: Tuesday, August 26, 2014 4:49 PM To: [email protected] Subject: [lng-odp] inconsistent naming Many API:s have set and get functions, this includes ODP. It seems like we have some naming inconsistencies. Set functions include "_set" in the name (as an infix). But the get functions sometimes include "_get", sometimes not. We ought to unify this naming, either always with or always without "_get". The following functions in linux-generic include "_get": olli@macmini:~/hacking/odp$ grep -r _get_ platform/linux-generic/include/api/ platform/linux-generic/include/api/odp_packet_io.h:odp_pktio_t odp_pktio_get_input(odp_packet_t pkt); platform/linux-generic/include/api/odp_queue.h:void *odp_queue_get_context(odp_queue_t queue); platform/linux-generic/include/api/odp_crypto.h:odp_crypto_get_ses_create_compl_status(odp_buffer_t completion_event, platform/linux-generic/include/api/odp_crypto.h:odp_crypto_get_ses_create_compl_session(odp_buffer_t completion_event, platform/linux-generic/include/api/odp_crypto.h:odp_crypto_get_operation_compl_status(odp_buffer_t completion_event, platform/linux-generic/include/api/odp_crypto.h:odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event); platform/linux-generic/include/api/odp_crypto.h:odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event); platform/linux-generic/include/api/odp_time.h:uint64_t odp_time_get_cycles(void); platform/linux-generic/include/api/odp_packet.h:size_t odp_packet_get_len(odp_packet_t pkt); More difficult to find which functions with get semantics that do not include "_get" in their names. I wouldn't mind that functions with get semantics should have no side effects (except if called with invalid parameters, e.g. invalid handle or output buffer pointer) and be easily identifiable. Functions with set semantics obviously have side effects. Functions in general will have side effects (e.g. create a pool of something, allocate an object) but they are not obvious set or get functions. I propose that side-effect free functions with get semantics use "_get" in their names. We might also consider tagging them with "__attribute__ ((pure))" (attribute const is often too strict), suitably hidden behind an ODP macro. _______________________________________________ lng-odp mailing list [email protected] http://lists.linaro.org/mailman/listinfo/lng-odp
