[asterisk-dev] [Code Review] Coding Guidelines, API naming convention, Line length limit

Tzafrir Cohen tzafrir.cohen at xorcom.com
Mon Mar 30 20:18:17 CDT 2009


On Mon, Mar 30, 2009 at 05:16:52PM -0700, Steve Edwards wrote:
> On Mon, 30 Mar 2009, Terry Wilson wrote:
> 
> > Am I the only one that finds line breaks uglier and harder to follow 
> > than line wrapping in the editor?
> 
> I don't know about the only one, but I do hope you are in the minority :)
> 
> The intelligent application of whitespace assists understanding. I know my 
> "style" is different than the current coding standard, but I find:
> 
>          if      (!mysql_real_connect(
>                            mysql_pointer // context
>                          , database_production_server
>                                          // host
>                          , database_username
>                                          // username
>                          , database_password
>                                          // password
>                          , database_database
>                                          // database
>                          , 0             // port
>                          , 0             // unix_socket
>                          , 0             // client_flag
>                          ))

This is caused by a function that has too many arguments. And as you
know, too many arguments lead to flames.

>                  {
>                  agi_verbose(
>                            "Failed to connect to the database"
>                                  ", mysql_error = \"%s\""
>                          , mysql_error(mysql_pointer)
>                          );
>                  return(EXIT_FAILURE);
>                  }
> 
> easier to comprehend and less fatiguing (less side to side eye movement, 
> more whitespace making it easier to target and focus) than:

I find it confusing that the comma is in the beginning. It also distotrs
the indentation, as it is not a "complete" character.

> 
>          if      (!mysql_real_connect(mysql_pointer, database_production_server, database_username, database_password, database_database, 0, 0, 0)) {
>                  agi_verbose("Failed to connect to the database, mysql_error = \"%s\"", mysql_error(mysql_pointer));
>                  return(EXIT_FAILURE);
>                  }


I'd go for:
	if (!mysql_real_connect(mysql_pointer, database_production_server, 
				database_username, database_password, 
				database_database, 0, 0, 0)) {
		agi_verbose("Failed to connect to the database, mysql_error = \"%s\"", 
				mysql_error(mysql_pointer));

-- 
               Tzafrir Cohen
icq#16849755              jabber:tzafrir.cohen at xorcom.com
+972-50-7952406           mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com  iax:guest at local.xorcom.com/tzafrir



More information about the asterisk-dev mailing list