Skip to contentSkip to conversation

arch/um/os-Linux/sys-i386/task_size.c: improve a bit

PATCH In review WANG Cong 2 participants 2 messages Apr 12, 2008 – Apr 14, 2008 User-mode Linux (UML)

lore
Share & tools
lore

WANG Cong

author
#0 lore raw

PATCH 1/1 arch/um/os-Linux/sys-i386/task_size.c: improve a bit

Improve this code a bit: check sigaction's return value and remove a useless fflush().

---

arch/um/os-Linux/sys-i386/task_size.c +8 -4
index 48d211b..2b5bba5 100644
@@ -88,7 +88,10 @@ unsigned long os_get_task_size(void)
 	sa.sa_handler = segfault;
 	sigemptyset(&sa.sa_mask);
 	sa.sa_flags = SA_NODEFER;
-	sigaction(SIGSEGV, &sa, &old);
+	if (sigaction(SIGSEGV, &sa, &old)) {
+		perror("os_get_task_size");
+		exit(1);
+	}
 
 	if (!page_ok(bottom)) {
 		fprintf(stderr, "Address 0x%x no good?\n",
@@ -110,11 +113,12 @@ unsigned long os_get_task_size(void)
 
 out:
 	/* Restore the old SIGSEGV handling */
-	sigaction(SIGSEGV, &old, NULL);
-
+	if (sigaction(SIGSEGV, &old, NULL)) {
+		perror("os_get_task_size");
+		exit(1);
+	}
 	top <<= UM_KERN_PAGE_SHIFT;
 	printf("0x%x\n", top);
-	fflush(stdout);
 
 	return top;
 }

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#1 lore raw
Quoted 2 lines · WANG Cong

Improve this code a bit: check sigaction's return value and remove a useless fflush().

This looks fine. BTW, some of the fflushing is on purpose, although the one you removed does indeed look useless. I want all output from early boot to hit the screen as soon as possible, even in the absence (so far) of a newline. So, if there's any doubt about whether a printf has a newline in it, it's flushed.

Jeff

Signature · 11 lines
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel