[Linux-ha-dev] [PATCH 05 of 10] ha_logd: Use C99 initializers, also correct max entity string length

Lars Ellenberg lars.ellenberg at linbit.com
Fri Nov 12 15:06:08 MST 2010


On Fri, Nov 12, 2010 at 05:04:40PM +0100, bs_lists at aakef.fastmail.fm wrote:
> # HG changeset patch
> # User Bernd Schubert <bernd.schubert at fastmail.fm>
> # Date 1289577717 -3600
> # Node ID b4cf81f29f57fa7b6afe1f6dfbf8efaa6511accd
> # Parent  39cc45ad8013fbf725254974070407fee2e1027b
> ha_logd: Use C99 initializers, also correct max entity string length
> 
> C99 initializers are more easy to read.

Likely breaks compatibility with alien platforms,
in case we still had it.
So I'm all for the patch ;-)

More comment below

> 
> Signed-off-by: Bernd Schubert <bschubert at ddn.com>
> 
> diff --git a/logd/ha_logd.c b/logd/ha_logd.c
> --- a/logd/ha_logd.c
> +++ b/logd/ha_logd.c
> @@ -87,18 +87,18 @@ static gboolean needs_shutdown = FALSE;
>  static struct {
>  	char		debugfile[MAXLINE];
>  	char		logfile[MAXLINE];
> -	char		entity[MAXLINE];
> +	char		entity[MAXENTITY];
>  	int		log_facility;
>  	mode_t		logmode;
>  	gboolean	syslogfmtmsgs;
>  } logd_config =
>  	{
> -		"",
> -		"",
> -		"logd",
> -		HA_LOG_FACILITY,
> -		0644,
> -		FALSE
> +		.debugfile = "",
> +		.logfile   = "",
> +		.entity    = "logd",
> +		.log_facility = HA_LOG_FACILITY,
> +		.logmode  = 0644,
> +		.syslogfmtmsgs = FALSE
>  	};
>  
>  static void	logd_log(const char * fmt, ...) G_GNUC_PRINTF(1,2);
> @@ -200,7 +200,7 @@ set_entity(const char * option)
>  		return FALSE;
>  	}
>  	cl_log(LOG_INFO, "setting entity to %s", option);
> -	strncpy(logd_config.entity, option, MAXLINE);
> +	strncpy(logd_config.entity, option, MAXENTITY);

Do we need an
	entity[MAXENTITY-1] = '\0';
just in case?

>  	return TRUE;
>  
>  }
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev at lists.linux-ha.org
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/

-- 
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.



More information about the Linux-HA-Dev mailing list