Re: [PATCH 2/2] added fputs() fgets() error handling

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

 



Hello.

On 11/04/2013 04:55 PM, Stanislaw Wadas wrote:

Change-Id: I787380dda981c7cee6508a4ff566d7ca9fb273cf

   This line shouldn't be present in the upstream patches.

Signed-off-by: Stanislaw Wadas <s.wadas@xxxxxxxxxxx>
---
  src/gadget.c |   12 +++++++++++-
  1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/gadget.c b/src/gadget.c
index faed675..ff4f3d5 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_LENGHT, fp);
+	if (ret == NULL) {
+	ERROR("read error");
+	fclose(fp);
+	return ret;

   You should indent the code in the block (by using tab).

+	}

  	fclose(fp);

[...]
@@ -136,7 +142,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;
+	}

   Same here.

WBR, Sergei

--
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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux