Skip to content

Commit a3ee259

Browse files
committed
Quiet warnings about casts of function types
It is easy enough to stop casting _PgObject_pureVirtualCalled to incompatible function types, as it makes modern compilers suspicious, and was only done in three places anyway.
1 parent 7de3b99 commit a3ee259

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

pljava-so/src/main/c/PgObject.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004-2020 Tada AB and other contributors, as listed below.
2+
* Copyright (c) 2004-2023 Tada AB and other contributors, as listed below.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the The BSD 3-Clause License
@@ -66,11 +66,6 @@ const char* PgObjectClass_getName(PgObjectClass self)
6666
return self->name;
6767
}
6868

69-
void _PgObject_pureVirtualCalled(PgObject object)
70-
{
71-
ereport(ERROR, (errmsg("Pure virtual method called")));
72-
}
73-
7469
char* PgObject_getClassName(jclass cls)
7570
{
7671
jstring jstr;

pljava-so/src/main/c/type/Type.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,31 @@ void Type_initialize(void)
10291029
initializeTypeBridges();
10301030
}
10311031

1032+
static Type unimplementedTypeObtainer(Oid typeId);
1033+
static jvalue unimplementedDatumCoercer(Type, Datum);
1034+
static Datum unimplementedObjectCoercer(Type, jobject);
1035+
1036+
static Type unimplementedTypeObtainer(Oid typeId)
1037+
{
1038+
ereport(ERROR,
1039+
(errmsg("no type obtainer registered for type oid %ud", typeId)));
1040+
pg_unreachable();
1041+
}
1042+
1043+
static jvalue unimplementedDatumCoercer(Type t, Datum d)
1044+
{
1045+
ereport(ERROR,
1046+
(errmsg("no datum coercer registered for type oid %ud", t->typeId)));
1047+
pg_unreachable();
1048+
}
1049+
1050+
static Datum unimplementedObjectCoercer(Type t, jobject o)
1051+
{
1052+
ereport(ERROR,
1053+
(errmsg("no object coercer registered for type oid %ud", t->typeId)));
1054+
pg_unreachable();
1055+
}
1056+
10321057
/*
10331058
* Abstract Type constructor
10341059
*/
@@ -1047,8 +1072,8 @@ TypeClass TypeClass_alloc2(
10471072
self->javaTypeName = "";
10481073
self->javaClass = 0;
10491074
self->canReplaceType = _Type_canReplaceType;
1050-
self->coerceDatum = (DatumCoercer)_PgObject_pureVirtualCalled;
1051-
self->coerceObject = (ObjectCoercer)_PgObject_pureVirtualCalled;
1075+
self->coerceDatum = unimplementedDatumCoercer;
1076+
self->coerceObject = unimplementedObjectCoercer;
10521077
self->createArrayType = _Type_createArrayType;
10531078
self->invoke = _Type_invoke;
10541079
self->getSRFCollector = _Type_getSRFCollector;
@@ -1137,9 +1162,7 @@ static void _registerType(
11371162

11381163
void Type_registerType(const char* javaTypeName, Type type)
11391164
{
1140-
_registerType(
1141-
type->typeId, javaTypeName, type,
1142-
(TypeObtainer)_PgObject_pureVirtualCalled);
1165+
_registerType(type->typeId, javaTypeName, type, unimplementedTypeObtainer);
11431166
}
11441167

11451168
void Type_registerType2(

pljava-so/src/main/include/pljava/PgObject_priv.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/*
2-
* Copyright (c) 2004, 2005, 2006 TADA AB - Taby Sweden
3-
* Distributed under the terms shown in the file COPYRIGHT
4-
* found in the root folder of this project or at
5-
* http://eng.tada.se/osprojects/COPYRIGHT.html
2+
* Copyright (c) 2004-2023 Tada AB and other contributors, as listed below.
63
*
7-
* @author Thomas Hallgren
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the The BSD 3-Clause License
6+
* which accompanies this distribution, and is available at
7+
* http://opensource.org/licenses/BSD-3-Clause
8+
*
9+
* Contributors:
10+
* Tada AB
11+
* Chapman Flack
812
*/
913
#ifndef __pljava_PgObject_priv_h
1014
#define __pljava_PgObject_priv_h
@@ -54,12 +58,6 @@ struct PgObject_
5458
PgObjectClass m_class;
5559
};
5660

57-
/*
58-
* Internal bogus. Someone forgot to replace a function
59-
* pointer somewhere.
60-
*/
61-
extern void _PgObject_pureVirtualCalled(PgObject self);
62-
6361
/*
6462
* Throw an exception indicating that wanted member could not be
6563
* found.

0 commit comments

Comments
 (0)