On Tue, Nov 05, 2013 at 03:22:54PM +0100, Stanislaw Wadas wrote: > Error handling was added to fputs()/fgets() functions. > > Signed-off-by: Stanislaw Wadas <s.wadas@xxxxxxxxxxx> > --- > Changes since v2: > - fixed code indentation > - removed unused variable ret > > Changes since v1: > - fixed typos in MAX_LENGTH throughout > > src/gadget.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/src/gadget.c b/src/gadget.c > index 3671a79..f976ce1 100644 > --- a/src/gadget.c > +++ b/src/gadget.c > @@ -93,6 +93,11 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) > goto out; > > ret = fgets(buf, MAX_LENGTH, fp); > + if (ret == NULL) { > + ERROR("read error"); > + fclose(fp); > + return ret; Still indent problems here on the return. > + } > > fclose(fp); > > @@ -136,7 +141,11 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) > return; > } > > - fputs(buf, fp); > + if (fputs(buf, fp) == EOF) { > + ERROR("write error"); > + fclose(fp); > + return; and here > + } > > fclose(fp); > } > -- > 1.7.9.5 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html