Title: [8693] trunk/scripts/kconfig: kconfig: fix warnings in fgets/fwrite usage
Revision
8693
Author
vapier
Date
2010-05-09 04:46:20 -0400 (Sun, 09 May 2010)

Log Message

kconfig: fix warnings in fgets/fwrite usage

Modified Paths


Diff

Modified: trunk/scripts/kconfig/conf.c (8692 => 8693)


--- trunk/scripts/kconfig/conf.c	2010-05-09 08:45:42 UTC (rev 8692)
+++ trunk/scripts/kconfig/conf.c	2010-05-09 08:46:20 UTC (rev 8693)
@@ -102,7 +102,7 @@
 		check_stdin();
 	case ask_all:
 		fflush(stdout);
-		fgets(line, 128, stdin);
+		xfgets(line, 128, stdin);
 		return 1;
 	default:
 		break;
@@ -304,7 +304,7 @@
 			check_stdin();
 		case ask_all:
 			fflush(stdout);
-			fgets(line, 128, stdin);
+			xfgets(line, 128, stdin);
 			strip(line);
 			if (line[0] == '?') {
 				print_help(menu);

Modified: trunk/scripts/kconfig/confdata.c (8692 => 8693)


--- trunk/scripts/kconfig/confdata.c	2010-05-09 08:45:42 UTC (rev 8692)
+++ trunk/scripts/kconfig/confdata.c	2010-05-09 08:46:20 UTC (rev 8693)
@@ -505,7 +505,7 @@
 				while (1) {
 					l = strcspn(str, "\"\\");
 					if (l) {
-						fwrite(str, l, 1, out);
+						xfwrite(str, l, 1, out);
 						str += l;
 					}
 					if (!*str)
@@ -758,8 +758,8 @@
 			while (1) {
 				l = strcspn(str, "\"\\");
 				if (l) {
-					fwrite(str, l, 1, out);
-					fwrite(str, l, 1, out_h);
+					xfwrite(str, l, 1, out);
+					xfwrite(str, l, 1, out_h);
 					str += l;
 				}
 				if (!*str)

Modified: trunk/scripts/kconfig/expr.c (8692 => 8693)


--- trunk/scripts/kconfig/expr.c	2010-05-09 08:45:42 UTC (rev 8692)
+++ trunk/scripts/kconfig/expr.c	2010-05-09 08:46:20 UTC (rev 8693)
@@ -1087,7 +1087,7 @@
 
 static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
 {
-	fwrite(str, strlen(str), 1, data);
+	xfwrite(str, strlen(str), 1, data);
 }
 
 void expr_fprint(struct expr *e, FILE *out)

Modified: trunk/scripts/kconfig/lkc.h (8692 => 8693)


--- trunk/scripts/kconfig/lkc.h	2010-05-09 08:45:42 UTC (rev 8692)
+++ trunk/scripts/kconfig/lkc.h	2010-05-09 08:46:20 UTC (rev 8693)
@@ -162,6 +162,30 @@
 	return sym->flags & SYMBOL_DEF_USER ? true : false;
 }
 
+#define internal_error(fmt, args...) \
+do { \
+	fprintf(stderr, "%s:%s:%i: %s: " fmt "\n", __FILE__, \
+		__func__, __LINE__, _("internal error"), ## args); \
+	exit(1); \
+} while (0)
+
+#define xfwrite(ptr, size, nmemb, stream) \
+({ \
+	size_t _nmemb = (nmemb); \
+	size_t ret = fwrite(ptr, size, _nmemb, stream); \
+	if (ret != _nmemb) \
+		internal_error("%s", _("fwrite() came up short")); \
+	ret; \
+})
+
+#define xfgets(s, size, stream) \
+({ \
+	char *ret = fgets(s, size, stream); \
+	if (ret == NULL) \
+		internal_error("%s", _("fgets() came up short")); \
+	ret; \
+})
+
 #ifdef __cplusplus
 }
 #endif
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to