Blame CodingStyle

Packit fcad23
The discussion about coding style on the net-snmp-coders mailing list
Packit fcad23
can be found at the following web address:
Packit fcad23
Packit fcad23
  http://sourceforge.net/mailarchive/message.php?msg_id=1009885
Packit fcad23
  (Thread "design proposal - coding style" started on 2001-02-08)
Packit fcad23
Packit fcad23
----------------------------------------------------------------------
Packit fcad23
Indentation: 
Packit fcad23
Packit fcad23
We've adopted the following indent style:
Packit fcad23
Packit fcad23
   indent -orig -nbc -bap -nut -nfca -T netsnmp_mib_handler -T netsnmp_handler_registration -T netsnmp_handler_args -T netsnmp_delegated_cache -T netsnmp_baby_steps_modes -T netsnmp_baby_steps_access_methods -T netsnmp_mode_handler_list -T netsnmp_mib_handler_methods -T netsnmp_monitor_callback_header -T netsnmp_monitor_set_request_data -T netsnmp_monitor_callback_cooperative -T netsnmp_old_api_info -T netsnmp_old_api_cache -T netsnmp_row_merge_status -T netsnmp_scalar_group -T netsnmp_set_info -T netsnmp_request_info -T netsnmp_set_info -T netsnmp_tree_cache -T netsnmp_agent_request_info -T netsnmp_cachemap -T netsnmp_agent_session -T netsnmp_stash_cache_info -T netsnmp_stash_cache_data -T netsnmp_request_group_item -T netsnmp_request_group -T netsnmp_table_array_callbacks -T netsnmp_table_row -T netsnmp_table_data -T netsnmp_table_data_set_storage -T netsnmp_table_data_set -T netsnmp_column_info -T netsnmp_table_registration_info -T netsnmp_table_request_info -T netsnmp_iterator_info -T netsnmp_tdata_row -T netsnmp_tdata -T netsnmp_subtree -T netsnmp_watcher_info -T netsnmp_arp_entry -T netsnmp_interface_stats -T netsnmp_interface_entry -T netsnmp_conf_if_list -T netsnmp_ipaddress_entry -T netsnmp_ipstats -T netsnmp_route_entry -T netsnmp_systemstats_entry -T netsnmp_tcpconn_entry -T netsnmp_udp_endpoint_entry -T netsnmp_container -T netsnmp_iterator -T netsnmp_data_list -T netsnmp_data_list_saveinfo -T netsnmp_factory -T netsnmp_file -T netsnmp_oid_stash_node -T netsnmp_oid_stash_save_info -T netsnmp_pdu -T netsnmp_request_list -T netsnmp_vardata -T netsnmp_callback_pass -T netsnmp_callback_info -T netsnmp_token_descr -T netsnmp_std_data -T netsnmp_transport -T netsnmp_transport_list -T netsnmp_tdomain -T netsnmp_line_info -T netsnmp_line_process_info -T netsnmp_token_value_index
Packit fcad23
Packit fcad23
[wow, what an annoying list!  The above -T list can be (re)generated by
Packit fcad23
running:
Packit fcad23
  perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h
Packit fcad23
in the include/net-snmp directory]
Packit fcad23
Packit fcad23
If possible, please run all new code submitted to the project through
Packit fcad23
the above command.  However, if sending a patch, please do *not* send
Packit fcad23
a patch that reformats the entire file.  Just the new sections of code
Packit fcad23
should be in the above style to make it easier for us to dissect what
Packit fcad23
you did in your patch.
Packit fcad23
Packit fcad23
Briefly, here's a description of the style:
Packit fcad23
Packit fcad23
	Blank lines:
Packit fcad23
		after procedures
Packit fcad23
		not (forced) after blocks of declarations or block comments
Packit fcad23
		multiple declarations not split onto separate lines
Packit fcad23
Packit fcad23
	Comments:
Packit fcad23
		Block comments indented 4 spaces from surrounding code
Packit fcad23
		Start/End on separate lines
Packit fcad23
		Solid '*' on the left of block comments
Packit fcad23
		"One-line" comments start in column 33
Packit fcad23
Packit fcad23
	Bracing/Indent/etc:
Packit fcad23
		K&R-style bracing (including "cuddle-else")
Packit fcad23
		'case' statements in line with 'switch'
Packit fcad23
		No space between procedure name and opening parenthesis
Packit fcad23
		variable declarations lined up, and start in column 16
Packit fcad23
		Procedure return type on a separate line to the procedure name
Packit fcad23
		Four character basic and continuation line indent
Packit fcad23
                No tabs used in the file, always use 8 spaces instead.
Packit fcad23
		Continuation parameters lined up with opening parenthesis
Packit fcad23
Packit fcad23
----------------------------------------------------------------------
Packit fcad23
Function names and Variable names:
Packit fcad23
Packit fcad23
should_be_like_this and notLikeThis
Packit fcad23
Packit fcad23
New public functions and defines should ideally start with a netsnmp_
Packit fcad23
or NETSNMP_ prefix, respectively.
Packit fcad23
Packit fcad23
----------------------------------------------------------------------
Packit fcad23
Structures:
Packit fcad23
Packit fcad23
We have decided to typedef all structures into names using the
Packit fcad23
following convention:
Packit fcad23
Packit fcad23
typedef struct netsnmp_wombat_s {
Packit fcad23
  int something_cool;
Packit fcad23
} netsnmp_wombat;
Packit fcad23
Packit fcad23
The important things to note here are that the struct name ends in a
Packit fcad23
"_s", the typedef name doesn't end in "_t", and the typedef is not to a
Packit fcad23
pointer and everything begins with "netsnmp_".
Packit fcad23