[PATCH 06/11] xkb: purge _XkbLibError.
Dan Nicholson
dbn.lists at gmail.com
Fri Jan 15 08:33:44 PST 2010
On Thu, Jan 14, 2010 at 9:32 PM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> This is a leftover from the shared header files and was defined away anyway.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> include/xkbsrv.h | 1 -
> xkb/xkbout.c | 28 ++------
> xkb/xkmread.c | 194 +++++++++++++----------------------------------------
> 3 files changed, 55 insertions(+), 168 deletions(-)
>
> diff --git a/include/xkbsrv.h b/include/xkbsrv.h
> index 6b702e8..bc74eef 100644
> --- a/include/xkbsrv.h
> +++ b/include/xkbsrv.h
> @@ -299,7 +299,6 @@ extern _X_EXPORT char * XkbBinDirectory;
>
> extern _X_EXPORT CARD32 xkbDebugFlags;
>
> -#define _XkbLibError(c,l,d) /* Epoch fail */
> #define _XkbErrCode2(a,b) ((XID)((((unsigned int)(a))<<24)|((b)&0xffffff)))
> #define _XkbErrCode3(a,b,c) _XkbErrCode2(a,(((unsigned int)(b))<<16)|(c))
> #define _XkbErrCode4(a,b,c,d) _XkbErrCode3(a,b,((((unsigned int)(c))<<8)|(d)))
> diff --git a/xkb/xkbout.c b/xkb/xkbout.c
> index 53f6841..91f5080 100644
> --- a/xkb/xkbout.c
> +++ b/xkb/xkbout.c
> @@ -110,10 +110,8 @@ Atom kcName;
> register unsigned i;
> char * alternate;
>
> - if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) {
> - _XkbLibError(_XkbErrMissingNames,"XkbWriteXKBKeycodes",0);
> + if ((!xkb)||(!xkb->names)||(!xkb->names->keys))
> return False;
> - }
> kcName= xkb->names->keycodes;
> if (kcName!=None)
> fprintf(file,"xkb_keycodes \"%s\" {\n",
> @@ -170,14 +168,10 @@ register unsigned i,n;
> XkbKeyTypePtr type;
> XkbKTMapEntryPtr entry;
>
> - if ((!xkb)||(!xkb->map)||(!xkb->map->types)) {
> - _XkbLibError(_XkbErrMissingTypes,"XkbWriteXKBKeyTypes",0);
> + if ((!xkb)||(!xkb->map)||(!xkb->map->types))
> return False;
> - }
> - if (xkb->map->num_types<XkbNumRequiredTypes) {
> - _XkbLibError(_XkbErrMissingReqTypes,"XkbWriteXKBKeyTypes",0);
> + if (xkb->map->num_types<XkbNumRequiredTypes)
> return 0;
> - }
> if ((xkb->names==NULL)||(xkb->names->types==None))
> fprintf(file,"xkb_types {\n\n");
> else fprintf(file,"xkb_types \"%s\" {\n\n",
> @@ -276,10 +270,8 @@ XkbWriteXKBCompatMap( FILE * file,
> register unsigned i;
> XkbSymInterpretPtr interp;
>
> - if ((!xkb)||(!xkb->compat)||(!xkb->compat->sym_interpret)) {
> - _XkbLibError(_XkbErrMissingCompatMap,"XkbWriteXKBCompatMap",0);
> + if ((!xkb)||(!xkb->compat)||(!xkb->compat->sym_interpret))
> return False;
> - }
> if ((xkb->names==NULL)||(xkb->names->compat==None))
> fprintf(file,"xkb_compatibility {\n\n");
> else fprintf(file,"xkb_compatibility \"%s\" {\n\n",
> @@ -355,14 +347,10 @@ Bool showActions;
>
> map= xkb->map;
> srv= xkb->server;
> - if ((!xkb)||(!map)||(!map->syms)||(!map->key_sym_map)) {
> - _XkbLibError(_XkbErrMissingSymbols,"XkbWriteXKBSymbols",0);
> + if ((!xkb)||(!map)||(!map->syms)||(!map->key_sym_map))
> return False;
> - }
> - if ((!xkb->names)||(!xkb->names->keys)) {
> - _XkbLibError(_XkbErrMissingNames,"XkbWriteXKBSymbols",0);
> + if ((!xkb->names)||(!xkb->names->keys))
> return False;
> - }
> if ((xkb->names==NULL)||(xkb->names->symbols==None))
> fprintf(file,"xkb_symbols {\n\n");
> else fprintf(file,"xkb_symbols \"%s\" {\n\n",
> @@ -802,10 +790,8 @@ XkbWriteXKBGeometry( FILE * file,
> register unsigned i,n;
> XkbGeometryPtr geom;
>
> - if ((!xkb)||(!xkb->geom)) {
> - _XkbLibError(_XkbErrMissingGeometry,"XkbWriteXKBGeometry",0);
> + if ((!xkb)||(!xkb->geom))
> return False;
> - }
> geom= xkb->geom;
> if (geom->name==None)
> fprintf(file,"xkb_geometry {\n\n");
> diff --git a/xkb/xkmread.c b/xkb/xkmread.c
> index 3c2df03..758f2af 100644
> --- a/xkb/xkmread.c
> +++ b/xkb/xkmread.c
> @@ -171,10 +171,8 @@ register unsigned int i,bit;
> unsigned int bound,named,tmp;
> int nRead=0;
>
> - if (XkbAllocServerMap(xkb,XkbVirtualModsMask,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmVirtualMods",0);
> + if (XkbAllocServerMap(xkb,XkbVirtualModsMask,0)!=Success)
> return -1;
> - }
> bound= XkmGetCARD16(file,&nRead);
> named= XkmGetCARD16(file,&nRead);
> for (i=tmp=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
> @@ -187,10 +185,8 @@ int nRead=0;
> }
> if ((i= XkbPaddedSize(tmp)-tmp)>0)
> nRead+= XkmSkipPadding(file,i);
> - if (XkbAllocNames(xkb,XkbVirtualModNamesMask,0,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmVirtualMods",0);
> + if (XkbAllocNames(xkb,XkbVirtualModNamesMask,0,0)!=Success)
> return -1;
> - }
> for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
> char name[100];
> if (named&bit) {
> @@ -226,28 +222,22 @@ XkbKeyNamePtr pN;
> else {
> if (minKC<xkb->min_key_code)
> xkb->min_key_code= minKC;
> - if (maxKC>xkb->max_key_code) {
> - _XkbLibError(_XkbErrBadValue,"ReadXkmKeycodes",maxKC);
> + if (maxKC>xkb->max_key_code)
> return -1;
> - }
> }
> nAl= XkmGetCARD8(file,&nRead);
> nRead+= XkmSkipPadding(file,1);
>
> #define WANTED (XkbKeycodesNameMask|XkbKeyNamesMask|XkbKeyAliasesMask)
> - if (XkbAllocNames(xkb,WANTED,0,nAl)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeycodes",0);
> + if (XkbAllocNames(xkb,WANTED,0,nAl)!=Success)
> return -1;
> - }
> if (name[0]!='\0') {
> xkb->names->keycodes= XkbInternAtom(name,False);
> }
>
> for (pN=&xkb->names->keys[minKC],i=minKC;i<=(int)maxKC;i++,pN++) {
> - if (fread(pN,1,XkbKeyNameLength,file)!=XkbKeyNameLength) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmKeycodes",0);
> + if (fread(pN,1,XkbKeyNameLength,file)!=XkbKeyNameLength)
> return -1;
> - }
> nRead+= XkbKeyNameLength;
> }
> if (nAl>0) {
> @@ -255,10 +245,8 @@ XkbKeyNamePtr pN;
> for (pAl= xkb->names->key_aliases,i=0;i<nAl;i++,pAl++) {
> int tmp;
> tmp= fread(pAl,1,2*XkbKeyNameLength,file);
> - if (tmp!=2*XkbKeyNameLength) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmKeycodes",0);
> + if (tmp!=2*XkbKeyNameLength)
> return -1;
> - }
> nRead+= 2*XkbKeyNameLength;
> }
> if (changes)
> @@ -284,55 +272,40 @@ XkbKTMapEntryPtr entry;
> xkmKTMapEntryDesc wire_entry;
> char buf[100];
>
> - if ((tmp= XkmGetCountedString(file,buf,100))<1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmKeyTypes",0);
> + if ((tmp= XkmGetCountedString(file,buf,100))<1)
> return -1;
> - }
> nRead+= tmp;
> if (buf[0]!='\0') {
> - if (XkbAllocNames(xkb,XkbTypesNameMask,0,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeyTypes",0);
> + if (XkbAllocNames(xkb,XkbTypesNameMask,0,0)!=Success)
> return -1;
> - }
> xkb->names->types= XkbInternAtom(buf,False);
> }
> num_types= XkmGetCARD16(file,&nRead);
> nRead+= XkmSkipPadding(file,2);
> if (num_types<1)
> return nRead;
> - if (XkbAllocClientMap(xkb,XkbKeyTypesMask,num_types)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeyTypes",0);
> + if (XkbAllocClientMap(xkb,XkbKeyTypesMask,num_types)!=Success)
> return nRead;
> - }
> +
> xkb->map->num_types= num_types;
> - if (num_types<XkbNumRequiredTypes) {
> - _XkbLibError(_XkbErrMissingReqTypes,"ReadXkmKeyTypes",0);
> + if (num_types<XkbNumRequiredTypes)
> return -1;
> - }
> type= xkb->map->types;
> for (i=0;i<num_types;i++,type++) {
> - if ((int)fread(&wire,SIZEOF(xkmKeyTypeDesc),1,file)<1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmKeyTypes",0);
> + if ((int)fread(&wire,SIZEOF(xkmKeyTypeDesc),1,file)<1)
> return -1;
> - }
> nRead+= SIZEOF(xkmKeyTypeDesc);
> if (((i==XkbOneLevelIndex)&&(wire.numLevels!=1))||
> (((i==XkbTwoLevelIndex)||(i==XkbAlphabeticIndex)||
> - ((i)==XkbKeypadIndex))&&(wire.numLevels!=2))) {
> - _XkbLibError(_XkbErrBadTypeWidth,"ReadXkmKeyTypes",i);
> + ((i)==XkbKeypadIndex))&&(wire.numLevels!=2)))
> return -1;
> - }
> tmp= wire.nMapEntries;
> XkmInsureTypedSize(type->map,type->map_count,&tmp,XkbKTMapEntryRec);
> - if ((wire.nMapEntries>0)&&(type->map==NULL)) {
> - _XkbLibError(_XkbErrBadValue,"ReadXkmKeyTypes",wire.nMapEntries);
> + if ((wire.nMapEntries>0)&&(type->map==NULL))
> return -1;
> - }
> for (n=0,entry= type->map;n<wire.nMapEntries;n++,entry++) {
> - if (fread(&wire_entry,SIZEOF(xkmKTMapEntryDesc),1,file)<(int)1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmKeyTypes",0);
> + if (fread(&wire_entry,SIZEOF(xkmKTMapEntryDesc),1,file)<(int)1)
> return -1;
> - }
> nRead+= SIZEOF(xkmKTMapEntryDesc);
> entry->active= (wire_entry.virtualMods==0);
> entry->level= wire_entry.level;
> @@ -344,10 +317,8 @@ char buf[100];
> if (((i==XkbOneLevelIndex)&&(strcmp(buf,"ONE_LEVEL")!=0))||
> ((i==XkbTwoLevelIndex)&&(strcmp(buf,"TWO_LEVEL")!=0))||
> ((i==XkbAlphabeticIndex)&&(strcmp(buf,"ALPHABETIC")!=0))||
> - ((i==XkbKeypadIndex)&&(strcmp(buf,"KEYPAD")!=0))) {
> - _XkbLibError(_XkbErrBadTypeName,"ReadXkmKeyTypes",0);
> + ((i==XkbKeypadIndex)&&(strcmp(buf,"KEYPAD")!=0)))
> return -1;
> - }
> if (buf[0]!='\0') {
> type->name= XkbInternAtom(buf,False);
> }
> @@ -358,15 +329,11 @@ char buf[100];
> XkbModsPtr pre;
> XkmInsureTypedSize(type->preserve,type->map_count,&tmp,
> XkbModsRec);
> - if (type->preserve==NULL) {
> - _XkbLibError(_XkbErrBadMatch,"ReadXkmKeycodes",0);
> + if (type->preserve==NULL)
> return -1;
> - }
> for (n=0,pre=type->preserve;n<wire.nMapEntries;n++,pre++) {
> - if (fread(&p_entry,SIZEOF(xkmModsDesc),1,file)<1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmKeycodes",0);
> + if (fread(&p_entry,SIZEOF(xkmModsDesc),1,file)<1)
> return -1;
> - }
> nRead+= SIZEOF(xkmModsDesc);
> pre->mask= p_entry.realMods;
> pre->real_mods= p_entry.realMods;
> @@ -375,10 +342,8 @@ char buf[100];
> }
> if (wire.nLevelNames>0) {
> int width= wire.numLevels;
> - if (wire.nLevelNames>(unsigned)width) {
> - _XkbLibError(_XkbErrBadMatch,"ReadXkmKeycodes",0);
> + if (wire.nLevelNames>(unsigned)width)
> return -1;
> - }
> XkmInsureTypedSize(type->level_names,type->num_levels,&width,Atom);
> if (type->level_names!=NULL) {
> for (n=0;n<wire.nLevelNames;n++) {
> @@ -420,16 +385,12 @@ int nRead=0;
> XkbCompatMapPtr compat;
> XkbAction *act;
>
> - if ((tmp= XkmGetCountedString(file,name,100))<1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmCompatMap",0);
> + if ((tmp= XkmGetCountedString(file,name,100))<1)
> return -1;
> - }
> nRead+= tmp;
> if (name[0]!='\0') {
> - if (XkbAllocNames(xkb,XkbCompatNameMask,0,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmCompatMap",0);
> + if (XkbAllocNames(xkb,XkbCompatNameMask,0,0)!=Success)
> return -1;
> - }
> xkb->names->compat= XkbInternAtom(name,False);
> }
> num_si= XkmGetCARD16(file,&nRead);
> @@ -582,14 +543,10 @@ char buf[100];
> unsigned tmp;
> int nRead=0;
>
> - if ((xkb->indicators==NULL)&&(XkbAllocIndicatorMaps(xkb)!=Success)) {
> - _XkbLibError(_XkbErrBadAlloc,"indicator rec",0);
> + if ((xkb->indicators==NULL)&&(XkbAllocIndicatorMaps(xkb)!=Success))
> return -1;
> - }
> - if (XkbAllocNames(xkb,XkbIndicatorNamesMask,0,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"indicator names",0);
> + if (XkbAllocNames(xkb,XkbIndicatorNamesMask,0,0)!=Success)
> return -1;
> - }
> nLEDs= XkmGetCARD8(file,&nRead);
> nRead+= XkmSkipPadding(file,3);
> xkb->indicators->phys_indicators= XkmGetCARD32(file,&nRead);
> @@ -597,18 +554,14 @@ int nRead=0;
> Atom name;
> XkbIndicatorMapPtr map;
>
> - if ((tmp=XkmGetCountedString(file,buf,100))<1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmIndicators",0);
> + if ((tmp=XkmGetCountedString(file,buf,100))<1)
> return -1;
> - }
> nRead+= tmp;
> if (buf[0]!='\0')
> name= XkbInternAtom(buf,False);
> else name= None;
> - if ((tmp=fread(&wire,SIZEOF(xkmIndicatorMapDesc),1,file))<1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmIndicators",0);
> + if ((tmp=fread(&wire,SIZEOF(xkmIndicatorMapDesc),1,file))<1)
> return -1;
> - }
> nRead+= tmp*SIZEOF(xkmIndicatorMapDesc);
> if (xkb->names) {
> xkb->names->indicators[wire.indicator-1]= name;
> @@ -672,10 +625,8 @@ int nRead=0;
> totalVModMaps= XkmGetCARD8(file,&nRead);
> if (XkbAllocNames(xkb,
> XkbSymbolsNameMask|XkbPhysSymbolsNameMask|XkbGroupNamesMask,
> - 0,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"physical names",0);
> + 0,0)!=Success)
> return -1;
> - }
> if ((buf[0]!='\0')&&(xkb->names)) {
> Atom name;
> name= XkbInternAtom(buf,0);
> @@ -695,35 +646,25 @@ int nRead=0;
> else xkb->names->groups[i]= None;
> }
> }
> - if (XkbAllocServerMap(xkb,XkbAllServerInfoMask,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"server map",0);
> + if (XkbAllocServerMap(xkb,XkbAllServerInfoMask,0)!=Success)
> return -1;
> - }
> - if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"client map",0);
> + if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success)
> return -1;
> - }
> - if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"controls",0);
> + if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success)
> return -1;
> - }
> if ((xkb->map==NULL)||(xkb->server==NULL))
> return -1;
> if (xkb->min_key_code<8) xkb->min_key_code= minKC;
> if (xkb->max_key_code<8) xkb->max_key_code= maxKC;
> if ((minKC>=8)&&(minKC<xkb->min_key_code))
> xkb->min_key_code= minKC;
> - if ((maxKC>=8)&&(maxKC>xkb->max_key_code)) {
> - _XkbLibError(_XkbErrBadValue,"keys in symbol map",maxKC);
> + if ((maxKC>=8)&&(maxKC>xkb->max_key_code))
> return -1;
> - }
> for (i=minKC;i<=(int)maxKC;i++) {
> Atom typeName[XkbNumKbdGroups];
> XkbKeyTypePtr type[XkbNumKbdGroups];
> - if ((tmp=fread(&wireMap,SIZEOF(xkmKeySymMapDesc),1,file))<1) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmSymbols",0);
> + if ((tmp=fread(&wireMap,SIZEOF(xkmKeySymMapDesc),1,file))<1)
> return -1;
> - }
> nRead+= tmp*SIZEOF(xkmKeySymMapDesc);
> bzero((char *)typeName,XkbNumKbdGroups*sizeof(Atom));
> bzero((char *)type,XkbNumKbdGroups*sizeof(XkbKeyTypePtr));
> @@ -736,10 +677,8 @@ int nRead=0;
> nRead+= tmp;
> }
> type[g]=FindTypeForKey(xkb,typeName[g],wireMap.width,NULL);
> - if (type[g]==NULL) {
> - _XkbLibError(_XkbErrMissingTypes,"ReadXkmSymbols",0);
> + if (type[g]==NULL)
> return -1;
> - }
> if (typeName[g]==type[g]->name)
> xkb->server->explicit[i]|= (1<<g);
> }
> @@ -892,10 +831,9 @@ register int r;
> tmp= fread(&rowWire,SIZEOF(xkmOverlayRowDesc),1,file);
> nRead+= tmp*SIZEOF(xkmOverlayRowDesc);
> row= XkbAddGeomOverlayRow(ol,rowWire.row_under,rowWire.num_keys);
> - if (!row) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeomOverlay",0);
> + if (!row)
> return nRead;
> - }
> +
> for (k=0;k<rowWire.num_keys;k++) {
> tmp= fread(&keyWire,SIZEOF(xkmOverlayKeyDesc),1,file);
> nRead+= tmp*SIZEOF(xkmOverlayKeyDesc);
> @@ -926,10 +864,9 @@ Atom nameAtom;
> section= XkbAddGeomSection(geom,nameAtom,sectionWire.num_rows,
> sectionWire.num_doodads,
> sectionWire.num_overlays);
> - if (!section) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeomSection",0);
> + if (!section)
> return nRead;
> - }
> +
> section->top= sectionWire.top;
> section->left= sectionWire.left;
> section->width= sectionWire.width;
> @@ -947,10 +884,8 @@ Atom nameAtom;
> tmp= fread(&rowWire,SIZEOF(xkmRowDesc),1,file);
> nRead+= SIZEOF(xkmRowDesc)*tmp;
> row= XkbAddGeomRow(section,rowWire.num_keys);
> - if (!row) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeycodes",0);
> + if (!row)
> return nRead;
> - }
> row->top= rowWire.top;
> row->left= rowWire.left;
> row->vertical= rowWire.vertical;
> @@ -958,10 +893,8 @@ Atom nameAtom;
> tmp= fread(&keyWire,SIZEOF(xkmKeyDesc),1,file);
> nRead+= SIZEOF(xkmKeyDesc)*tmp;
> key= XkbAddGeomKey(row);
> - if (!key) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeomSection",0);
> + if (!key)
> return nRead;
> - }
> memcpy(key->name.name,keyWire.name,XkbKeyNameLength);
> key->gap= keyWire.gap;
> key->shape_ndx= keyWire.shape_ndx;
> @@ -1009,10 +942,8 @@ XkbGeometrySizesRec sizes;
> sizes.num_sections= wireGeom.num_sections;
> sizes.num_doodads= wireGeom.num_doodads;
> sizes.num_key_aliases= wireGeom.num_key_aliases;
> - if (XkbAllocGeometry(xkb,&sizes)!=Success) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
> + if (XkbAllocGeometry(xkb,&sizes)!=Success)
> return nRead;
> - }
> geom= xkb->geom;
> geom->name= XkbInternAtom(buf,False);
> geom->width_mm= wireGeom.width_mm;
> @@ -1024,19 +955,15 @@ XkbGeometrySizesRec sizes;
> for (i=0;i<wireGeom.num_properties;i++) {
> nRead+= XkmGetCountedString(file,buf,100);
> nRead+= XkmGetCountedString(file,val,1024);
> - if (XkbAddGeomProperty(geom,buf,val)==NULL) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
> + if (XkbAddGeomProperty(geom,buf,val)==NULL)
> return nRead;
> - }
> }
> }
> if (wireGeom.num_colors>0) {
> for (i=0;i<wireGeom.num_colors;i++) {
> nRead+= XkmGetCountedString(file,buf,100);
> - if (XkbAddGeomColor(geom,buf,i)==NULL) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
> + if (XkbAddGeomColor(geom,buf,i)==NULL)
> return nRead;
> - }
> }
> }
> geom->base_color= &geom->colors[wireGeom.base_color_ndx];
> @@ -1054,20 +981,16 @@ XkbGeometrySizesRec sizes;
> tmp= fread(&shapeWire,SIZEOF(xkmShapeDesc),1,file);
> nRead+= tmp*SIZEOF(xkmShapeDesc);
> shape= XkbAddGeomShape(geom,nameAtom,shapeWire.num_outlines);
> - if (!shape) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
> + if (!shape)
> return nRead;
> - }
> for (n=0;n<shapeWire.num_outlines;n++) {
> register int p;
> xkmPointDesc ptWire;
> tmp= fread(&olWire,SIZEOF(xkmOutlineDesc),1,file);
> nRead+= tmp*SIZEOF(xkmOutlineDesc);
> ol= XkbAddGeomOutline(shape,olWire.num_points);
> - if (!ol) {
> - _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
> + if (!ol)
> return nRead;
> - }
> ol->num_points= olWire.num_points;
> ol->corner_radius= olWire.corner_radius;
> for (p=0;p<olWire.num_points;p++) {
> @@ -1106,10 +1029,8 @@ XkbGeometrySizesRec sizes;
> if ((wireGeom.num_key_aliases>0)&&(geom->key_aliases)) {
> int sz= XkbKeyNameLength*2;
> int num= wireGeom.num_key_aliases;
> - if (fread(geom->key_aliases,sz,num,file)!=num) {
> - _XkbLibError(_XkbErrBadLength,"ReadXkmGeometry",0);
> + if (fread(geom->key_aliases,sz,num,file)!=num)
> return -1;
> - }
> nRead+= (num*sz);
> geom->num_key_aliases= num;
> }
> @@ -1124,12 +1045,8 @@ int nRead=0;
>
> hdr= (('x'<<24)|('k'<<16)|('m'<<8)|XkmFileVersion);
> tmp= XkmGetCARD32(file,&nRead);
> - if (tmp!=hdr) {
> - if ((tmp&(~0xff))==(hdr&(~0xff))) {
> - _XkbLibError(_XkbErrBadFileVersion,"XkmProbe",tmp&0xff);
> - }
> + if (tmp!=hdr)
> return 0;
> - }
> return 1;
> }
>
> @@ -1142,15 +1059,9 @@ unsigned i,size_toc;
>
> hdr= (('x'<<24)|('k'<<16)|('m'<<8)|XkmFileVersion);
> tmp= XkmGetCARD32(file,&nRead);
> - if (tmp!=hdr) {
> - if ((tmp&(~0xff))==(hdr&(~0xff))) {
> - _XkbLibError(_XkbErrBadFileVersion,"XkmReadTOC",tmp&0xff);
> - }
> - else {
> - _XkbLibError(_XkbErrBadFileType,"XkmReadTOC",tmp);
> - }
> + if (tmp!=hdr)
> return 0;
> - }
> +
> fread(file_info,SIZEOF(xkmFileInfo),1,file);
> size_toc= file_info->num_toc;
> if (size_toc>max_toc) {
> @@ -1178,11 +1089,8 @@ unsigned which= need|want;
>
> if (!XkmReadTOC(file,&fileInfo,MAX_TOC,toc))
> return which;
> - if ((fileInfo.present&need)!=need) {
> - _XkbLibError(_XkbErrIllegalContents,"XkmReadFile",
> - need&(~fileInfo.present));
> + if ((fileInfo.present&need)!=need)
> return which;
> - }
> if (*xkb==NULL)
> *xkb= XkbAllocKeyboard();
> for (i=0;i<fileInfo.num_toc;i++) {
> @@ -1219,8 +1127,6 @@ unsigned which= need|want;
> tmp= ReadXkmGeometry(file,*xkb);
> break;
> default:
> - _XkbLibError(_XkbErrBadImplementation,
> - XkbConfigText(tmpTOC.type,XkbMessage),0);
> tmp= 0;
> break;
> }
> @@ -1229,10 +1135,6 @@ unsigned which= need|want;
> which&= ~(1<<toc[i].type);
> (*xkb)->defined|= (1<<toc[i].type);
> }
> - if (nRead!=tmpTOC.size) {
> - _XkbLibError(_XkbErrBadLength,XkbConfigText(tmpTOC.type,XkbMessage),
> - nRead-tmpTOC.size);
> - }
> }
> return which;
> }
Until the glorious future where the server doesn't have to write out a
keymap file to pass to xkbcomp, it might be a better idea to replace
these with some sort of LogMessage. That could obviously be a
different patch, but you might lose track of what the relevant
conditions are if this goes in first.
What do you think?
--
Dan
More information about the xorg-devel
mailing list