[Nut-upsdev] [nut-commits] svn commit r3448 - trunk/drivers (extern variables)

Charles Lepple clepple at gmail.com
Sun Feb 19 03:28:02 UTC 2012


On Feb 18, 2012, at 10:19 PM, Charles Lepple wrote:

> Author: clepple-guest
> Date: Sun Feb 19 03:19:02 2012
> New Revision: 3448
> URL: http://trac.networkupstools.org/projects/nut/changeset/3448
> 
> Log:
> Don't allocate storage for variables in bcmxcp.h
> 
> The header files should declare variables as extern, and they should be
> allocated in only one .c file (not all of the files which include the .h
> file). This was causing multiple symbol definitions on Mac OS X.

Actually, the NUT developer guide recommends using static. But this patch fixes the build failure, and changes the semantics as little as possible. If someone wants to change it to static later, be sure that it does what you mean.

> Patch by Daniel Macks:
> http://fink.cvs.sourceforge.net/viewvc/fink/experimental/dmacks/finkinfo/nut.patch?revision=1.1&view=markup
> 
> Modified:
>   trunk/drivers/bcmxcp.c
>   trunk/drivers/bcmxcp.h
> 
> Modified: trunk/drivers/bcmxcp.c
> ==============================================================================
> --- trunk/drivers/bcmxcp.c	Thu Feb 16 16:05:56 2012	(r3447)
> +++ trunk/drivers/bcmxcp.c	Sun Feb 19 03:19:02 2012	(r3448)
> @@ -186,6 +186,15 @@
> };
> 
> 
> +/* allocate storage for shared variables (extern in bcmxcp.h) */
> +BCMXCP_METER_MAP_ENTRY_t
> +	bcmxcp_meter_map[BCMXCP_METER_MAP_MAX];
> +BCMXCP_ALARM_MAP_ENTRY_t
> +	bcmxcp_alarm_map[BCMXCP_ALARM_MAP_MAX];
> +BCMXCP_STATUS_t
> +	bcmxcp_status;
> +
> +
> /* get_word function from nut driver metasys.c */
> int get_word(const unsigned char *buffer)	/* return an integer reading a word in the supplied buffer */
> {
> 
> Modified: trunk/drivers/bcmxcp.h
> ==============================================================================
> --- trunk/drivers/bcmxcp.h	Thu Feb 16 16:05:56 2012	(r3447)
> +++ trunk/drivers/bcmxcp.h	Sun Feb 19 03:19:02 2012	(r3448)
> @@ -358,7 +358,7 @@
> 	unsigned int meter_block_index;			/* The position of this meter in the UPS meter block */
> }	BCMXCP_METER_MAP_ENTRY_t;
> 
> -BCMXCP_METER_MAP_ENTRY_t
> +extern BCMXCP_METER_MAP_ENTRY_t
> 	bcmxcp_meter_map[BCMXCP_METER_MAP_MAX];
> 
> typedef	struct { /* Entry in BCM/XCP - UPS mapping table */
> @@ -366,7 +366,7 @@
> 	const char *alarm_desc;			/* Description of this alarm */
> }	BCMXCP_ALARM_MAP_ENTRY_t;
> 
> -BCMXCP_ALARM_MAP_ENTRY_t
> +extern BCMXCP_ALARM_MAP_ENTRY_t
> 	bcmxcp_alarm_map[BCMXCP_ALARM_MAP_MAX];
> 
> typedef	struct {				/* A place to store status info and other data not for NUT */
> @@ -378,7 +378,7 @@
> 	int alarm_replace_battery;		/* Battery needs replacement! */
> }	BCMXCP_STATUS_t;
> 
> -BCMXCP_STATUS_t
> +extern BCMXCP_STATUS_t
> 	bcmxcp_status;
> 
> int checksum_test(const unsigned char*);
> 
> _______________________________________________
> nut-commits mailing list
> nut-commits at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-commits

-- 
Charles Lepple
clepple at gmail






More information about the Nut-upsdev mailing list