Thread (1 message) 1 message, 1 author, 2020-09-08

Re: [PATCH 5/7] maintenance: add start/stop subcommands

From: Junio C Hamano <hidden>
Date: 2020-09-08 19:32:52

SZEDER Gábor [off-list ref] writes:
quoted
+int cmd__crontab(int argc, const char **argv)
+{
+	char a;
So 'a' is a char...
quoted
+	FILE *from, *to;
+
+	if (argc == 3 && !strcmp(argv[2], "-l")) {
+		from = fopen(argv[1], "r");
+		if (!from)
+			return 0;
+		to = stdout;
+	} else if (argc == 2) {
+		from = stdin;
+		to = fopen(argv[1], "w");
+	} else
+		return error("unknown arguments");
+
+	while ((a = fgetc(from)) != EOF)
fgetc() returns an int, which is assigned to a char, which is then
compared to whatever EOF might be on the platform.  Apparently this
casting and comparison doesn't work as expected on s390x (I haven't
even tried to think it through...), and instead of detecting EOF and
exiting we end up in an endless loop writing 0xff bytes to 'cron.txt',
while 'git maintenance start' in vain waits for 'test-crontab' to
exit.
Ah, is this fun with unsigned char never comparing equal to -1?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help