[PATCH] teach sparse about '-o FILE'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



sparse knows about the '-o FILE' option, parses it
but does nothing with it.

Change this by redirecting stdout to FILE.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 lib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib.c b/lib.c
index 07a5b9cda..ba5f1ffeb 100644
--- a/lib.c
+++ b/lib.c
@@ -23,6 +23,7 @@
  * THE SOFTWARE.
  */
 #include <ctype.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stddef.h>
@@ -673,6 +674,8 @@ static char **handle_switch_o(char *arg, char **next)
 	if (!strcmp (arg, "o")) {       // "-o foo"
 		if (!*++next)
 			die("argument to '-o' is missing");
+		if (!freopen(*next, "w", stdout))
+			die("error: cannot open %s: %s", *next, strerror(errno));
 	}
 	// else "-ofoo"
 
-- 
2.19.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux