[PATCH:libFS 3/7] Remove unused internal helper _FSAllocScratch

Alan Coopersmith alan.coopersmith at oracle.com
Tue Jan 7 16:02:23 PST 2014


Since we build with -export-symbols-regex '^FS.*', it wasn't available
to callers outside libFS, and was never called by anything inside libFS.

Seems to have been imported from XlibInt.c without ever being used.
The _FSserver fields that it used (and nothing else did) are replaced
with "unused" placeholders to maintain struct layout/size.

Flagged by cppcheck 1.62:
[FSlibInt.c:973]: (style) The function '_FSAllocScratch' is never used.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 include/X11/fonts/FSlib.h |    4 ++--
 src/FSlibInt.c            |   19 -------------------
 src/FSlibint.h            |    1 -
 3 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/include/X11/fonts/FSlib.h b/include/X11/fonts/FSlib.h
index 11b3ba6..1cd7f13 100644
--- a/include/X11/fonts/FSlib.h
+++ b/include/X11/fonts/FSlib.h
@@ -148,8 +148,8 @@ struct _FSServer {
     int         ext_number;
     Bool        (*event_vec[132]) (FSServer *, FSEvent *, fsEvent *);
     Status	(*wire_vec[132]) (FSServer *, FSEvent *, fsEvent *);
-    char       *scratch_buffer;
-    unsigned long scratch_length;
+    void         *unused_1; /* previously scratch_buffer */
+    unsigned long unused_2; /* previously scratch_length */
     FSSyncHandler synchandler;
     unsigned long flags;
     struct _XtransConnInfo *trans_conn; /* transport connection object */
diff --git a/src/FSlibInt.c b/src/FSlibInt.c
index cd996d1..48091cf 100644
--- a/src/FSlibInt.c
+++ b/src/FSlibInt.c
@@ -964,25 +964,6 @@ _FSDefaultError(
 FSIOErrorHandler _FSIOErrorFunction = _FSDefaultIOError;
 FSErrorHandler _FSErrorFunction = _FSDefaultError;
 
-/*
- * This routine can be used to (cheaply) get some memory within a single
- * Xlib routine for scratch space.  It is reallocated from the same place
- * each time, unless the library needs a large scratch space.
- */
-char       *
-_FSAllocScratch(
-    register FSServer	*svr,
-    unsigned long	 nbytes)
-{
-    if (nbytes > svr->scratch_length) {
-	if (svr->scratch_buffer != NULL)
-	    FSfree(svr->scratch_buffer);
-	return (svr->scratch_length = nbytes,
-		svr->scratch_buffer = FSmalloc(nbytes));
-    }
-    return (svr->scratch_buffer);
-}
-
 int
 FSFree(char *data)
 {
diff --git a/src/FSlibint.h b/src/FSlibint.h
index 7669778..b50509b 100644
--- a/src/FSlibint.h
+++ b/src/FSlibint.h
@@ -93,7 +93,6 @@ extern int _FSDefaultIOError ( FSServer *svr ) _X_NORETURN;
 extern int _FSPrintDefaultError ( FSServer *svr, FSErrorEvent *event,
 				  FILE *fp );
 extern int _FSDefaultError ( FSServer *svr, FSErrorEvent *event );
-extern char * _FSAllocScratch ( FSServer *svr, unsigned long nbytes );
 extern void _FSFreeQ ( void );
 
 extern FSErrorHandler  FSSetErrorHandler ( FSErrorHandler handler );
-- 
1.7.9.2



More information about the xorg-devel mailing list