[PATCH] Fix path.c's function pointer defenitions.

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

 



int isn't big enough to hold a FILE* / DIR* on some systems, this causes
segfaults in calls that try to use the resulting FILE* / DIR*:

  TESTSUITE: ERR: 'testsuite_rootfs_fopen' [1176160] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: testsuite_rootfs_fopen
  FAIL: testsuite/test-testsuite
  ...
  TESTSUITE: ERR: 'loaded_1' [1176166] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: loaded_1
  FAIL: testsuite/test-loaded
  ...
  TESTSUITE: ERR: 'from_alias' [1176181] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: from_alias
  FAIL: testsuite/test-new-module

For reference on my system:

  sizeof(int) = 4
  sizeof(long) = 8
  sizeof(FILE*) = 8
  sizeof(DIR*) = 8
---
 testsuite/path.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/testsuite/path.c b/testsuite/path.c
index 86025dc..60df4a0 100644
--- a/testsuite/path.c
+++ b/testsuite/path.c
@@ -98,7 +98,7 @@ TS_EXPORT FILE *fopen(const char *path, const char *mode)
 {
 	const char *p;
 	char buf[PATH_MAX * 2];
-	static int (*_fopen)(const char *path, const char *mode);
+	static FILE* (*_fopen)(const char *path, const char *mode);
 
 	if (!get_rootpath(__func__))
 		return NULL;
@@ -109,7 +109,7 @@ TS_EXPORT FILE *fopen(const char *path, const char *mode)
 	if (p == NULL)
 		return NULL;
 
-	return (void *) (long) (*_fopen)(p, mode);
+	return (*_fopen)(p, mode);
 }
 
 TS_EXPORT int open(const char *path, int flags, ...)
@@ -200,7 +200,7 @@ TS_EXPORT DIR *opendir(const char *path)
 {
 	const char *p;
 	char buf[PATH_MAX * 2];
-	static int (*_opendir)(const char *path);
+	static DIR* (*_opendir)(const char *path);
 
 	if (!get_rootpath(__func__))
 		return NULL;
@@ -211,5 +211,5 @@ TS_EXPORT DIR *opendir(const char *path)
 	if (p == NULL)
 		return NULL;
 
-	return (void *)(long)(*_opendir)(p);
+	return (*_opendir)(p);
 }
-- 
1.7.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux