[PATCH] src/swapon.c: initiate p to NULL

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



when run make, show:
swapon.c:135:3: warning: 'p' may be used uninitialized in this function
[-Wmaybe-uninitialized]
   memcpy(p, buf, BUF_SIZE);
      ^~~~~~~~~~~~~~~~~~~~~~~~
fix it.

Signed-off-by: Sun Ke <sunke32@xxxxxxxxxx>
---
 src/swapon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/swapon.c b/src/swapon.c
index afaed405..fe8949a3 100644
--- a/src/swapon.c
+++ b/src/swapon.c
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
 		.sa_handler	= handle_signal,
 	};
 	enum verbs verb = TEST_SWAPON;
-	void *p;
+	void *p = NULL;
 	ssize_t sz;
 	int fd = -1;
 	int ret, c;
-- 
2.13.6




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux