util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/5] sfdisk: do not depend on arch for packed attribute
@ 2011-12-20 13:42         ` Davidlohr Bueso
  2012-01-05 16:29           ` Karel Zak
  0 siblings, 1 reply; 10+ messages in thread
From: Davidlohr Bueso @ 2011-12-20 13:42 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

From: Davidlohr Bueso <dave@gnu.org>

The packed gcc function attribute is moved to c.h and the arch-specific checks are removed
since there is no harm in other platforms having the attribute, it will just make no difference.
---
 fdisk/sfdisk.c |    9 ---------
 include/c.h    |    3 +++
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 979eadc..fdc63d6 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -115,15 +115,6 @@ error(char *s, ...) {
 }
 
 /*
- * arm needs PACKED - use it everywhere?
- */
-#if defined(__GNUC__) && (defined(__arm__) || defined(__alpha__))
-#define PACKED __attribute__ ((packed))
-#else
-#define PACKED
-#endif
-
-/*
  *  A. About seeking
  */
 
diff --git a/include/c.h b/include/c.h
index 073615e..26582e4 100644
--- a/include/c.h
+++ b/include/c.h
@@ -39,10 +39,13 @@
 	__typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \
 })
 
+# define PACKED __attribute__ ((packed))
+
 #else /* !__GNUC__ */
 # define __must_be_array(a)	0
 # define __attribute__(_arg_)
 # define ignore_result(x) ((void) (x))
+# define PACKED
 #endif /* !__GNUC__ */
 
 /*
-- 
1.7.4.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] fdisk: remove packed definitions
@ 2011-12-20 13:42       ` Davidlohr Bueso
  2011-12-20 13:42         ` [PATCH 3/5] sfdisk: do not depend on arch for packed attribute Davidlohr Bueso
  2011-12-22  2:33         ` [PATCH 4/5] fdisk: remove packed definitions Guillem Jover
  0 siblings, 2 replies; 10+ messages in thread
From: Davidlohr Bueso @ 2011-12-20 13:42 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

From: Davidlohr Bueso <dave@gnu.org>

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 fdisk/fdisk.h |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h
index 84be09c..d8832e9 100644
--- a/fdisk/fdisk.h
+++ b/fdisk/fdisk.h
@@ -26,12 +26,6 @@
 #define cround(n)	(display_in_cyl_units ? ((n)/units_per_sector)+1 : (n))
 #define scround(x)	(((x)+units_per_sector-1)/units_per_sector)
 
-#if defined(__GNUC__) && (defined(__arm__) || defined(__alpha__))
-# define PACKED __attribute__ ((packed))
-#else
-# define PACKED
-#endif
-
 struct partition {
 	unsigned char boot_ind;         /* 0x80 - active */
 	unsigned char head;             /* starting head */
-- 
1.7.4.1






^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 4/5] fdisk: remove packed definitions
  2011-12-20 13:42       ` [PATCH 4/5] fdisk: remove packed definitions Davidlohr Bueso
  2011-12-20 13:42         ` [PATCH 3/5] sfdisk: do not depend on arch for packed attribute Davidlohr Bueso
@ 2011-12-22  2:33         ` Guillem Jover
  1 sibling, 0 replies; 10+ messages in thread
From: Guillem Jover @ 2011-12-22  2:33 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: Karel Zak, util-linux

Hi!

On Tue, 2011-12-20 at 14:42:07 +0100, Davidlohr Bueso wrote:
> @@ -26,12 +26,6 @@
>  #define cround(n)	(display_in_cyl_units ? ((n)/units_per_sector)+1 : (n))
>  #define scround(x)	(((x)+units_per_sector-1)/units_per_sector)
>  
> -#if defined(__GNUC__) && (defined(__arm__) || defined(__alpha__))
> -# define PACKED __attribute__ ((packed))
> -#else
> -# define PACKED
> -#endif
> -
>  struct partition {
>  	unsigned char boot_ind;         /* 0x80 - active */
>  	unsigned char head;             /* starting head */

Why not merge this commit with the previous one? They are for the same
logical change, and otherwise it termporarily introduces a warning.

regards,
guillem

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] lscpu: fix compiler warnings
@ 2012-01-04 22:28   ` Davidlohr Bueso
       [not found]     ` <1324994959-24298-1-git-send-email-gaowanlong@cn.fujitsu.com>
  2012-01-05 16:30     ` [PATCH] lscpu: fix compiler warnings Karel Zak
  0 siblings, 2 replies; 10+ messages in thread
From: Davidlohr Bueso @ 2012-01-04 22:28 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

From: Davidlohr Bueso <dave@gnu.org>

The string format is not being passed triggering:

    lscpu.c: In function ‘read_hypervisor’:
    lscpu.c:545:4: warning: format not a string literal and no format arguments
    lscpu.c: In function ‘get_cell_header’:
    lscpu.c:904:2: warning: format not a string literal and no format arguments
    lscpu.c:904:2: warning: format not a string literal and no format arguments

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 sys-utils/lscpu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 0a7841d..5214a12 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -542,7 +542,7 @@ read_hypervisor(struct lscpu_desc *desc)
 			str = strchr(buf, ':');
 			if (!str)
 				continue;
-			if (asprintf(&str, str + 1) == -1)
+			if (asprintf(&str, "%s", str + 1) == -1)
 				errx(EXIT_FAILURE, _("failed to allocate memory"));
 			/* remove leading, trailing and repeating whitespace */
 			while (*str == ' ')
@@ -901,7 +901,7 @@ get_cell_header(struct lscpu_desc *desc, int col,
 		if (desc->ncaches)
 			return buf;
 	}
-	snprintf(buf, bufsz, coldescs[col].name);
+	snprintf(buf, bufsz, "%s", coldescs[col].name);
 	return buf;
 }
 
-- 
1.7.4.1




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 1/2] blkdev: add is_blkdev function
@ 2012-01-04 23:02 ` Davidlohr Bueso
  2012-01-04 22:28   ` [PATCH] lscpu: fix compiler warnings Davidlohr Bueso
  2012-01-05 16:31   ` [PATCH 1/2] blkdev: add is_blkdev function Karel Zak
  0 siblings, 2 replies; 10+ messages in thread
From: Davidlohr Bueso @ 2012-01-04 23:02 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

From: Davidlohr Bueso <dave@gnu.org>

We should have the most basic of checks in this library to see whether or not a block device is being used.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 include/blkdev.h |    3 +++
 lib/blkdev.c     |    6 ++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/blkdev.h b/include/blkdev.h
index 1a9119d..6b18879 100644
--- a/include/blkdev.h
+++ b/include/blkdev.h
@@ -86,6 +86,9 @@ struct hd_geometry {
 };
 #endif
 
+/* are we working with block device? */
+int is_blkdev(int fd);
+
 /* Determine size in bytes */
 off_t blkdev_find_size (int fd);
 
diff --git a/lib/blkdev.c b/lib/blkdev.c
index 9138b0d..c59386d 100644
--- a/lib/blkdev.c
+++ b/lib/blkdev.c
@@ -35,6 +35,12 @@ blkdev_valid_offset (int fd, off_t offset) {
 	return 1;
 }
 
+int is_blkdev(int fd)
+{
+	struct stat st;
+	return (fstat(fd, &st) == 0 && S_ISBLK(st.st_mode));
+}
+
 off_t
 blkdev_find_size (int fd) {
 	uintmax_t high, low = 0;
-- 
1.7.4.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] sfdisk: use is_blkdev
@ 2012-01-04 23:02 Davidlohr Bueso
  2012-01-04 23:02 ` [PATCH 1/2] blkdev: add is_blkdev function Davidlohr Bueso
  2012-01-05 16:31 ` [PATCH 2/2] sfdisk: use is_blkdev Karel Zak
  0 siblings, 2 replies; 10+ messages in thread
From: Davidlohr Bueso @ 2012-01-04 23:02 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

From: Davidlohr Bueso <dave@gnu.org>

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 fdisk/sfdisk.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 469e87f..70a5e2a 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -794,13 +794,6 @@ reread_ioctl(int fd) {
     return 0;
 }
 
-static int
-is_blockdev(int fd) {
-    struct stat statbuf;
-
-    return (fstat(fd, &statbuf) == 0 && S_ISBLK(statbuf.st_mode));
-}
-
 /* reread after writing */
 static int
 reread_disk_partition(char *dev, int fd) {
@@ -808,7 +801,7 @@ reread_disk_partition(char *dev, int fd) {
     fflush(stdout);
     sync();
 
-    if (reread_ioctl(fd) && is_blockdev(fd)) {
+    if (reread_ioctl(fd) && is_blkdev(fd)) {
 	do_warn(_("The command to re-read the partition table failed.\n"
 		  "Run partprobe(8), kpartx(8) or reboot your system now,\n"
 		  "before using mkfs\n"));
-- 
1.7.4.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/5] sfdisk: do not depend on arch for packed attribute
  2011-12-20 13:42         ` [PATCH 3/5] sfdisk: do not depend on arch for packed attribute Davidlohr Bueso
@ 2012-01-05 16:29           ` Karel Zak
  0 siblings, 0 replies; 10+ messages in thread
From: Karel Zak @ 2012-01-05 16:29 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

On Tue, Dec 20, 2011 at 02:42:05PM +0100, Davidlohr Bueso wrote:
>  fdisk/sfdisk.c |    9 ---------
>  include/c.h    |    3 +++
>  2 files changed, 3 insertions(+), 9 deletions(-)

On Tue, Dec 20, 2011 at 02:42:07PM +0100, Davidlohr Bueso wrote:
>  fdisk/fdisk.h |    6 ------
>  1 files changed, 0 insertions(+), 6 deletions(-)

  I have removed the PACKED macro at all and used __attribute__
  keyword in the code.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] lscpu: fix compiler warnings
  2012-01-04 22:28   ` [PATCH] lscpu: fix compiler warnings Davidlohr Bueso
       [not found]     ` <1324994959-24298-1-git-send-email-gaowanlong@cn.fujitsu.com>
@ 2012-01-05 16:30     ` Karel Zak
  1 sibling, 0 replies; 10+ messages in thread
From: Karel Zak @ 2012-01-05 16:30 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

On Wed, Jan 04, 2012 at 11:28:59PM +0100, Davidlohr Bueso wrote:
>  sys-utils/lscpu.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

 Good catch. Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] blkdev: add is_blkdev function
  2012-01-04 23:02 ` [PATCH 1/2] blkdev: add is_blkdev function Davidlohr Bueso
  2012-01-04 22:28   ` [PATCH] lscpu: fix compiler warnings Davidlohr Bueso
@ 2012-01-05 16:31   ` Karel Zak
  1 sibling, 0 replies; 10+ messages in thread
From: Karel Zak @ 2012-01-05 16:31 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

On Thu, Jan 05, 2012 at 12:02:06AM +0100, Davidlohr Bueso wrote:
>  include/blkdev.h |    3 +++
>  lib/blkdev.c     |    6 ++++++
>  2 files changed, 9 insertions(+), 0 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] sfdisk: use is_blkdev
  2012-01-04 23:02 [PATCH 2/2] sfdisk: use is_blkdev Davidlohr Bueso
  2012-01-04 23:02 ` [PATCH 1/2] blkdev: add is_blkdev function Davidlohr Bueso
@ 2012-01-05 16:31 ` Karel Zak
  1 sibling, 0 replies; 10+ messages in thread
From: Karel Zak @ 2012-01-05 16:31 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

On Thu, Jan 05, 2012 at 12:02:11AM +0100, Davidlohr Bueso wrote:
>  fdisk/sfdisk.c |    9 +--------
>  1 files changed, 1 insertions(+), 8 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-01-05 16:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-04 23:02 [PATCH 2/2] sfdisk: use is_blkdev Davidlohr Bueso
2012-01-04 23:02 ` [PATCH 1/2] blkdev: add is_blkdev function Davidlohr Bueso
2012-01-04 22:28   ` [PATCH] lscpu: fix compiler warnings Davidlohr Bueso
     [not found]     ` <1324994959-24298-1-git-send-email-gaowanlong@cn.fujitsu.com>
2011-12-20 13:42       ` [PATCH 4/5] fdisk: remove packed definitions Davidlohr Bueso
2011-12-20 13:42         ` [PATCH 3/5] sfdisk: do not depend on arch for packed attribute Davidlohr Bueso
2012-01-05 16:29           ` Karel Zak
2011-12-22  2:33         ` [PATCH 4/5] fdisk: remove packed definitions Guillem Jover
2012-01-05 16:30     ` [PATCH] lscpu: fix compiler warnings Karel Zak
2012-01-05 16:31   ` [PATCH 1/2] blkdev: add is_blkdev function Karel Zak
2012-01-05 16:31 ` [PATCH 2/2] sfdisk: use is_blkdev Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).