Bug 61369

Summary: EAI_NODATA and EAI_NONAME are define to be the same.
Product: Base System Reporter: marka
Component: binAssignee: Hajimu UMEMOTO <ume>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description marka 2004-01-14 21:30:13 UTC
	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.

Fix: 

Remove the offending #define.
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");
		}
	}
Comment 1 Kris Kennaway freebsd_committer freebsd_triage 2004-01-15 04:31:52 UTC
Responsible Changed
From-To: freebsd-bugs->ume

Assign to responsible committer
Comment 2 Hajimu UMEMOTO freebsd_committer freebsd_triage 2004-01-15 15:10:28 UTC
State Changed
From-To: open->closed

I've just removed EAI_NODATA.