[PATCH:xfs 1/3] Delete unused extension code
Alan Coopersmith
alan.coopersmith at oracle.com
Fri May 23 18:04:09 PDT 2014
No extensions were defined, but the code was ready for them, just in
case someone came up with one. If someone ever does, they can restore
from git history or an old tarball - until then, less code for us to
maintain & worry about checking for proper encoding/decoding of protocol.
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
difs/dispatch.c | 2 +-
difs/extensions.c | 216 +++-------------------------------------------------
difs/main.c | 2 -
include/extentst.h | 35 ---------
4 files changed, 11 insertions(+), 244 deletions(-)
diff --git a/difs/dispatch.c b/difs/dispatch.c
index a85d306..36c82ef 100644
--- a/difs/dispatch.c
+++ b/difs/dispatch.c
@@ -398,7 +398,7 @@ DoSendErrToClient(
.sequenceNumber = client->sequence,
.timestamp = GetTimeInMillis(),
.major_opcode = ((fsReq *) client->requestBuffer)->reqType,
- .minor_opcode = MinorOpcodeOfRequest(client)
+ .minor_opcode = 0
};
int extralen = 0;
diff --git a/difs/extensions.c b/difs/extensions.c
index 2bb2405..5a3d6d9 100644
--- a/difs/extensions.c
+++ b/difs/extensions.c
@@ -55,146 +55,12 @@ in this Software without prior written authorization from The Open Group.
#include "difs.h"
#include "dispatch.h"
-#define EXTENSION_BASE 128
-#define EXTENSION_EVENT_BASE 64
-#define LAST_EVENT 128
-#define LAST_ERROR 255
-
-static ExtensionEntry **extensions = (ExtensionEntry **) NULL;
-
-static int lastEvent = EXTENSION_EVENT_BASE;
-static int lastError = FirstExtensionError;
-static int NumExtensions = 0;
-
-
-ExtensionEntry *
-AddExtension(
- char *name,
- int num_events,
- int num_errors,
- int (*main_proc) (ClientPtr),
- int (*smain_proc) (ClientPtr),
- void (*closedown_proc) (struct _ExtensionEntry *),
- unsigned short (*minorop_proc) (ClientPtr))
-{
- int i;
- ExtensionEntry *ext,
- **newexts;
-
- if (!main_proc || !smain_proc || !closedown_proc || !minorop_proc)
- return ((ExtensionEntry *) 0);
- if ((lastEvent + num_events > LAST_EVENT) ||
- (unsigned) (lastError + num_errors > LAST_ERROR))
- return ((ExtensionEntry *) 0);
- ext = (ExtensionEntry *) fsalloc(sizeof(ExtensionEntry));
- if (!ext)
- return ((ExtensionEntry *) 0);
- ext->num_aliases = 0;
- ext->aliases = (char **) NULL;
- ext->name = strdup(name);
- if (!ext->name) {
- fsfree(ext);
- return ((ExtensionEntry *) 0);
- }
- i = NumExtensions;
- newexts = (ExtensionEntry **) fsrealloc(extensions,
- (i + 1) * sizeof(ExtensionEntry *));
- if (!newexts) {
- fsfree(ext->name);
- fsfree(ext);
- return ((ExtensionEntry *) 0);
- }
- NumExtensions++;
- extensions = newexts;
- extensions[i] = ext;
- ext->index = i;
- ext->base = i + EXTENSION_BASE;
- ext->CloseDown = closedown_proc;
- ext->MinorOpcode = minorop_proc;
- ProcVector[i + EXTENSION_BASE] = main_proc;
- SwappedProcVector[i + EXTENSION_BASE] = smain_proc;
- if (num_events) {
- ext->eventBase = lastEvent;
- ext->eventLast = lastEvent + num_events;
- lastEvent += num_events;
- } else {
- ext->eventBase = 0;
- ext->eventLast = 0;
- }
- if (num_errors) {
- ext->errorBase = lastError;
- ext->errorLast = lastError + num_errors;
- lastError += num_errors;
- } else {
- ext->errorBase = 0;
- ext->errorLast = 0;
- }
- return ext;
-}
-
-Bool
-AddExtensionAlias(char *alias, ExtensionEntry *ext)
-{
- char *name;
- char **aliases;
-
- aliases = (char **) fsrealloc(ext->aliases,
- (ext->num_aliases + 1) * sizeof(char *));
- if (!aliases)
- return FALSE;
- ext->aliases = aliases;
- name = strdup(alias);
- if (!name)
- return FALSE;
- ext->aliases[ext->num_aliases++] = name;
- return TRUE;
-}
-
-unsigned short
-StandardMinorOpcode(ClientPtr client)
-{
- return ((fsReq *) client->requestBuffer)->data;
-}
-
-unsigned short
-MinorOpcodeOfRequest(ClientPtr client)
-{
- unsigned char major;
-
- major = ((fsReq *) client->requestBuffer)->reqType;
- if (major < EXTENSION_BASE)
- return 0;
- major -= EXTENSION_BASE;
- if (major >= NumExtensions)
- return 0;
- return (*extensions[major]->MinorOpcode) (client);
-}
-
-void
-CloseDownExtensions(void)
-{
- int i,
- j;
-
- for (i = NumExtensions - 1; i >= 0; i--) {
- (*extensions[i]->CloseDown) (extensions[i]);
- NumExtensions = i;
- fsfree(extensions[i]->name);
- for (j = extensions[i]->num_aliases; --j >= 0;)
- fsfree(extensions[i]->aliases[j]);
- fsfree(extensions[i]->aliases);
- fsfree(extensions[i]);
- }
- fsfree(extensions);
- extensions = (ExtensionEntry **) NULL;
- lastEvent = EXTENSION_EVENT_BASE;
- lastError = FirstExtensionError;
-}
-
-void
-InitExtensions(void)
-{
-}
+/*
+ * Provides the protocol handlers for the Query & List Extensions
+ * requests, which are effectively no-ops, as no extensions are
+ * implemented, and the extension framework has been removed.
+ * (See the git history in the unlikely event you need to create one.)
+ */
int
ProcQueryExtension(ClientPtr client)
@@ -203,42 +69,15 @@ ProcQueryExtension(ClientPtr client)
.type = FS_Reply,
.sequenceNumber = client->sequence,
.length = SIZEOF(fsQueryExtensionReply) >> 2,
+ .present = fsFalse,
.major_opcode = 0
};
- int i,
- j;
REQUEST(fsQueryExtensionReq);
REQUEST_AT_LEAST_SIZE(fsQueryExtensionReq);
- if (!NumExtensions) {
- reply.present = fsFalse;
- } else {
- for (i = 0; i < NumExtensions; i++) {
- if ((strlen(extensions[i]->name) == stuff->nbytes) &&
- !strncmp((char *) &stuff[1], extensions[i]->name,
- (int) stuff->nbytes))
- break;
- for (j = extensions[i]->num_aliases; --j >= 0;) {
- if ((strlen(extensions[i]->aliases[j]) == stuff->nbytes) &&
- !strncmp((char *) &stuff[1], extensions[i]->aliases[j],
- (int) stuff->nbytes))
- break;
- }
- if (j >= 0)
- break;
- }
- if (i == NumExtensions) {
- reply.present = fsFalse;
- } else {
- reply.present = fsTrue;
- reply.major_opcode = extensions[i]->base;
- reply.first_event = extensions[i]->eventBase;
- reply.first_error = extensions[i]->errorBase;
- }
-
- }
+ /* No defined extensions to query for, so always just return False */
WriteReplyToClient(client, SIZEOF(fsQueryExtensionReply), &reply);
return client->noClientException;
}
@@ -248,50 +87,15 @@ ProcListExtensions(ClientPtr client)
{
fsListExtensionsReply reply = {
.type = FS_Reply,
- .nExtensions = NumExtensions,
+ .nExtensions = 0,
.sequenceNumber = client->sequence,
.length = SIZEOF(fsListExtensionsReply) >> 2
};
- char *bufptr,
- *buffer = NULL;
- int total_length = 0;
REQUEST(fsListExtensionsReq);
REQUEST_SIZE_MATCH(fsListExtensionsReq);
- if (NumExtensions) {
- int i,
- j;
-
- for (i = 0; i < NumExtensions; i++) {
- total_length += strlen(extensions[i]->name) + 1;
- reply.nExtensions += extensions[i]->num_aliases;
- for (j = extensions[i]->num_aliases; --j >= 0;)
- total_length += strlen(extensions[i]->aliases[j]) + 1;
- }
- reply.length += (total_length + 3) >> 2;
- buffer = bufptr = (char *) ALLOCATE_LOCAL(total_length);
- if (!buffer) {
- SendErrToClient(client, FSBadAlloc, NULL);
- return FSBadAlloc;
- }
- for (i = 0; i < NumExtensions; i++) {
- int len;
-
- *bufptr++ = len = strlen(extensions[i]->name);
- memmove( bufptr, extensions[i]->name, len);
- bufptr += len;
- for (j = extensions[i]->num_aliases; --j >= 0;) {
- *bufptr++ = len = strlen(extensions[i]->aliases[j]);
- memmove( bufptr, extensions[i]->aliases[j], len);
- bufptr += len;
- }
- }
- }
+ /* No defined extensions, so always just return empty list */
WriteReplyToClient(client, SIZEOF(fsListExtensionsReply), &reply);
- if (total_length) {
- WriteToClient(client, total_length, buffer);
- DEALLOCATE_LOCAL(buffer);
- }
return client->noClientException;
}
diff --git a/difs/main.c b/difs/main.c
index a202a53..4177fcb 100644
--- a/difs/main.c
+++ b/difs/main.c
@@ -128,7 +128,6 @@ main(int argc, char *argv[])
if (!InitClientResources(serverClient))
FatalError("couldn't init server resources\n");
- InitExtensions();
InitAtoms();
InitFonts();
SetConfigValues();
@@ -146,7 +145,6 @@ main(int argc, char *argv[])
#endif
/* clean up per-cycle stuff */
- CloseDownExtensions();
if ((dispatchException & DE_TERMINATE) || drone_server)
break;
fsfree(ConnectionInfo);
diff --git a/include/extentst.h b/include/extentst.h
index 9010d87..e21f8cb 100644
--- a/include/extentst.h
+++ b/include/extentst.h
@@ -48,44 +48,9 @@ in this Software without prior written authorization from The Open Group.
#ifndef _EXTENTST_H_
#define _EXTENTST_H_
-typedef struct _ExtensionEntry {
- int index;
- void (*CloseDown) (struct _ExtensionEntry*);
- char *name;
- int base;
- int eventBase;
- int eventLast;
- int errorBase;
- int errorLast;
- int num_aliases;
- char **aliases;
- pointer extPrivate;
- unsigned short (*MinorOpcode) (ClientPtr);
-} ExtensionEntry;
-
extern void (*EventSwapVector[]) (fsError *, fsError *);
-#if 0
-typedef void (*ExtensionLookupProc) (char *name, GCPtr pGC);
-
-typedef struct _ProcEntry {
- char *name;
- ExtensionLookupProc proc;
-} ProcEntryRec, *ProcEntryPtr;
-
-extern ExtensionEntry *AddExtension();
-extern ExtensionLookupProc LookupProc(char *name, GCPtr pGC);
-extern Bool RegisterProc();
-#endif
-
-extern ExtensionEntry * AddExtension ( char *name, int num_events, int num_errors, int (*main_proc) (ClientPtr), int (*smain_proc) (ClientPtr), void (*closedown_proc) (struct _ExtensionEntry *), unsigned short (*minorop_proc) (ClientPtr) );
-
-extern Bool AddExtensionAlias(char *alias, ExtensionEntry *ext);
extern int ProcListExtensions(ClientPtr client);
extern int ProcQueryExtension(ClientPtr client);
-extern unsigned short MinorOpcodeOfRequest(ClientPtr client);
-extern unsigned short StandardMinorOpcode(ClientPtr client);
-extern void CloseDownExtensions(void);
-extern void InitExtensions(void);
#endif /* _EXTENTST_H_ */
--
1.7.9.2
More information about the xorg-devel
mailing list