From: John Hodge Date: Thu, 20 Oct 2011 04:01:10 +0000 (+0800) Subject: Applications/cat - Added error check X-Git-Tag: rel0.13~29 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9f6b2744216253fd5f7e7c8f1479abb42e2c3c68;p=tpg%2Facess2.git Applications/cat - Added error check --- diff --git a/Usermode/Applications/Makefile.tpl b/Usermode/Applications/Makefile.tpl index 13397655..542fd815 100644 --- a/Usermode/Applications/Makefile.tpl +++ b/Usermode/Applications/Makefile.tpl @@ -4,7 +4,7 @@ # CFLAGS += -Wall -Werror -fno-builtin -fno-stack-protector -g -LDFLAGS += +LDFLAGS += -g _BIN := $(OUTPUTDIR)$(DIR)/$(BIN) _OBJPREFIX := obj-$(ARCH)/ diff --git a/Usermode/Applications/cat_src/main.c b/Usermode/Applications/cat_src/main.c index e63a97c1..a389c108 100644 --- a/Usermode/Applications/cat_src/main.c +++ b/Usermode/Applications/cat_src/main.c @@ -30,6 +30,7 @@ int main(int argc, char *argv[]) do { num = read(fd, buf, BUF_SIZE); + if(num < 0) break; buf[num] = '\0'; printf("%s", buf); } while(num == BUF_SIZE);