linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libmtd: Variable name same as function name causing compile to fail (Android)
@ 2012-01-09 16:20 Thomas Cannon
  2012-01-13 21:59 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Cannon @ 2012-01-09 16:20 UTC (permalink / raw)
  To: Thomas Cannon; +Cc: linux-mtd

When compiling mtd-utils against Android's bionic libc using the
supplied cross compiler environment it errors:

lib/libmtd.c: In function 'dev_node2num':
lib/libmtd.c:444: error: called object 'major' is not a function
lib/libmtd.c:445: error: called object 'minor' is not a function
lib/libmtd.c: In function 'mtd_probe_node':
lib/libmtd.c:1384: error: called object 'major' is not a function
lib/libmtd.c:1385: error: called object 'minor' is not a function

This patch updates the variable names for "major" and "minor" in two
places. It then compiles cleanly.

Tested against mtd-utils 1.4.9
Applied with patch -p1 -i libmtd.patch

Signed-off-by: Thomas Cannon <mail at thomascannon.net>
Cc: linux-mtd at lists.infradead.org
---

diff -crB a/lib/libmtd.c b/lib/libmtd.c
*** a/lib/libmtd.c	2012-01-09 14:38:56.000000000 +0000
--- b/lib/libmtd.c	2012-01-09 20:57:34.363506783 +0000
***************
*** 429,435 ****
  static int dev_node2num(struct libmtd *lib, const char *node, int *mtd_num)
  {
  	struct stat st;
! 	int i, major, minor;
  	struct mtd_info info;

  	if (stat(node, &st))
--- 429,435 ----
  static int dev_node2num(struct libmtd *lib, const char *node, int *mtd_num)
  {
  	struct stat st;
! 	int i, majorx, minorx;
  	struct mtd_info info;

  	if (stat(node, &st))
***************
*** 441,448 ****
  		return -1;
  	}

! 	major = major(st.st_rdev);
! 	minor = minor(st.st_rdev);

  	if (mtd_get_info((libmtd_t *)lib, &info))
  		return -1;
--- 441,448 ----
  		return -1;
  	}

! 	majorx = major(st.st_rdev);
! 	minorx = minor(st.st_rdev);

  	if (mtd_get_info((libmtd_t *)lib, &info))
  		return -1;
***************
*** 459,465 ****
  			return -1;
  		}

! 		if (major1 == major && minor1 == minor) {
  			errno = 0;
  			*mtd_num = i;
  			return 0;
--- 459,465 ----
  			return -1;
  		}

! 		if (major1 == majorx && minor1 == minorx) {
  			errno = 0;
  			*mtd_num = i;
  			return 0;
***************
*** 1369,1375 ****
  {
  	struct stat st;
  	struct mtd_info info;
! 	int i, major, minor;
  	struct libmtd *lib = (struct libmtd *)desc;

  	if (stat(node, &st))
--- 1369,1375 ----
  {
  	struct stat st;
  	struct mtd_info info;
! 	int i, majorx, minorx;
  	struct libmtd *lib = (struct libmtd *)desc;

  	if (stat(node, &st))
***************
*** 1381,1388 ****
  		return -1;
  	}

! 	major = major(st.st_rdev);
! 	minor = minor(st.st_rdev);

  	if (mtd_get_info((libmtd_t *)lib, &info))
  		return -1;
--- 1381,1388 ----
  		return -1;
  	}

! 	majorx = major(st.st_rdev);
! 	minorx = minor(st.st_rdev);

  	if (mtd_get_info((libmtd_t *)lib, &info))
  		return -1;
***************
*** 1402,1408 ****
  			return -1;
  		}

! 		if (major1 == major && minor1 == minor)
  			return 1;
  	}

--- 1402,1408 ----
  			return -1;
  		}

! 		if (major1 == majorx && minor1 == minorx)
  			return 1;
  	}

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

* Re: [PATCH] libmtd: Variable name same as function name causing compile to fail (Android)
  2012-01-09 16:20 [PATCH] libmtd: Variable name same as function name causing compile to fail (Android) Thomas Cannon
@ 2012-01-13 21:59 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2012-01-13 21:59 UTC (permalink / raw)
  To: Thomas Cannon; +Cc: linux-mtd

On Mon, 2012-01-09 at 16:20 +0000, Thomas Cannon wrote:
> When compiling mtd-utils against Android's bionic libc using the
> supplied cross compiler environment it errors:
> 
> lib/libmtd.c: In function 'dev_node2num':
> lib/libmtd.c:444: error: called object 'major' is not a function
> lib/libmtd.c:445: error: called object 'minor' is not a function
> lib/libmtd.c: In function 'mtd_probe_node':
> lib/libmtd.c:1384: error: called object 'major' is not a function
> lib/libmtd.c:1385: error: called object 'minor' is not a function
> 
> This patch updates the variable names for "major" and "minor" in two
> places. It then compiles cleanly.

I've tweaked the patch a bit and picked different names: mjr and mnr
instead of strange majorx and minorx. I've also re-named major1 and
minor1 variables for consistency.

Pushed to mtd-utils.git, thanks!

Artem.

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

end of thread, other threads:[~2012-01-13 21:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-09 16:20 [PATCH] libmtd: Variable name same as function name causing compile to fail (Android) Thomas Cannon
2012-01-13 21:59 ` Artem Bityutskiy

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