Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Dec 2011 19:05:45 +0530
From:      "Jayachandran C." <jchandra@freebsd.org>
To:        freebsd-sparc64@freebsd.org
Cc:        marius@freebsd.org
Subject:   [PATCH] fix OF_finddevice return value checks on sparc64
Message-ID:  <CA%2B7sy7B41x0izHhgHLGDFutSUr3y0dCYPnj3tnVfcYfeprhpLQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
While going thru the OF_finddevice usage in kernel (to fix up the FDT
interface) I noticed that  a few calls made to OF_finddevice in
sparc64 does not check the return value correctly.

The error return is -1 not 0, and since the value is unsigned,
checking it for '< 0' does not work either.  The attached patch fixes
this.

Regards,
JC.

[-- Attachment #2 --]
Index: sys/sparc64/sparc64/vm_machdep.c
===================================================================
--- sys/sparc64/sparc64/vm_machdep.c	(revision 228197)
+++ sys/sparc64/sparc64/vm_machdep.c	(working copy)
@@ -368,7 +368,7 @@
 		(cell_t)bspec
 	};
 
-	if ((chosen = OF_finddevice("/chosen")) != 0) {
+	if ((chosen = OF_finddevice("/chosen")) != -1) {
 		if (OF_getprop(chosen, "bootpath", bspec, sizeof(bspec)) == -1)
 			bspec[0] = '\0';
 		bspec[sizeof(bspec) - 1] = '\0';
Index: sys/sparc64/sparc64/ofw_machdep.c
===================================================================
--- sys/sparc64/sparc64/ofw_machdep.c	(revision 228197)
+++ sys/sparc64/sparc64/ofw_machdep.c	(working copy)
@@ -52,7 +52,7 @@
 	phandle_t node;
 	struct idprom idp;
 
-	if ((node = OF_finddevice("/options")) > 0 &&
+	if ((node = OF_finddevice("/options")) != -1 &&
 	    OF_getprop(node, "local-mac-address?", buf, sizeof(buf)) > 0) {
 		buf[sizeof(buf) - 1] = '\0';
 		if (strcmp(buf, "true") == 0 &&

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B7sy7B41x0izHhgHLGDFutSUr3y0dCYPnj3tnVfcYfeprhpLQ>