bin/61369: EAI_NODATA and EAI_NONAME are define to be the same.

Mark Andrews marka at isc.org
Wed Jan 14 13:30:37 PST 2004


>Number:         61369
>Category:       bin
>Synopsis:       EAI_NODATA and EAI_NONAME are define to be the same.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 14 13:30:13 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Mark Andrews
>Release:        FreeBSD 5.2 i386
>Organization:
ISC
>Environment:

	FreeBSD 5.2

	$FreeBSD: src/include/netdb.h,v 1.30 2003/10/24 06:53:12 ume Exp $

>Description:

	EAI_NODATA and EAI_NONAME are defined to be the same.

	This breaks switch statements that look at result codes
	from getaddrinfo().

	This change has made every portable application that does
	this have to change from

	#ifdef EAI_NODATA
        case EAI_NODATA:
	#endif

	to

	#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME)
        case EAI_NODATA:
	#endif

	Having a unused result code doesn't hurt anyone.

	Removing the result code causes some pain but portable
	applications already have that pain.  EAI_NODATA doesn't
	exist on all platforms already.

	Defining EAI_NODATA to be EAI_NONAME is just plain wrong
	as it breaks existing unbroken code.

	I really am not looking forward to the bug reports that
	I will have to handle about this.  I've already got
	one.

>How-To-Repeat:
	
	#include <netdb.h>

	main() {
		int i = 0;
		/* i = getaddrinfo(....); */
		switch (i) {
		case EAI_NONAME:
			printf("EAI_NONAME\n");
			break;
	#ifdef EAI_NODATA
		case EAI_NODATA:
			printf("EAI_NODATA\n");
			break;
	#endif
		default:
			printf("default\n");
		}
	}

>Fix:

	Remove the offending #define.


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list