There is a fundamental problem with the SaStringT type as it is currently defined:
typedef char* SaStringT;
When SaStringT is defined like this, it is impossible to declare a string constant using it. For example, a variable decleared like this:
const SaStringT x;
has the following meaning:
char *const x;
i.e., it is only the pointer x that is constant, not the string that it is pointing to.
There are several possible ways to support constant strings in the SAF APIs:
1) Introduce a new type SaCharT, and use SaCharT pointers in the API calls instead of SaStringT. Since SaStringT is defined as a character pointer, it should be possible to replace occurrences of SaStringT with SaCharT* without breaking backwards compatibility.
2) Replace the SaStringT typedef with a C preprocessor macro, like this:
#define SaStringT char*
3) Intruduce a new type SaConstStringT:
typedef const char* SaConstStringT;
The proposal is to go for 3), and to begin with only define the new type. The new type can later on be used when defining new APIs.
One could ask what the point is with these SAF defined replacements for
primitive types ?
If the only definition is the provided binding to C then they are
totally redundant. If the idea is to allow some kind of language portability
then the binding to C should be regarded as more of an example than a
hard binding.
I would go for (2) since it is the least intrusive and avoids a new
questionable redundant definition of a primitive type.
Diff:
Yes I would also go for (3) now.
I see in this ticket that a few months ago I was for (2).
But I think it is better (if possible) not to tamper with the original
SAF definitions, mainly because it easily explodes into a documentation
nightmare.
I think you should send out a patch for review.
It should go into osaf/libs/saf/include/saAis_B_5_14.
Why 14 for the OpenSAF specific extension?
Lets keep all OpenSAF extensions to SAF APIs have the file extension
numer related to the OpenSAF release.
For some reason we started with 11 for IMM in OpenSAF 4.2.
Lets increment by one for each OpenSAF release where there is any
extension and use the same number for the extension across all
services.
changeset: 5098:eb646cb93f0c
tag: tip
parent: 5095:a29089d1696c
user: Anders Widell anders.widell@ericsson.com
date: Wed Apr 02 16:47:39 2014 +0200
summary: osaf: Add definition of the new type SaConstStringT [#625]
[staging:eb646c]
Related
Commit: [eb646c]
Tickets:
#625changeset: 5133:a2360a43963f
tag: tip
user: Anders Widell anders.widell@ericsson.com
date: Thu Apr 10 09:41:05 2014 +0200
summary: osaf: Fix RPM build by adding saAis_B_5_14.h to spec [#625]
[staging:a2360a]
Related
Commit: [a2360a]
Tickets:
#625