[konkretcmpi] Handle ValueMap with same Values in MOF
Radek Novacek
rnovacek at fedoraproject.org
Mon Aug 6 08:24:27 UTC 2012
commit ec1137a7c693e8e54941a2d079cdd98ecd1d1d61
Author: Radek Novacek <rnovacek at redhat.com>
Date: Mon Aug 6 10:24:02 2012 +0200
Handle ValueMap with same Values in MOF
konkretcmpi-0.8.7-fix-same-enum-values.patch | 59 ++++++++++++++++++++++++++
konkretcmpi.spec | 8 +++-
2 files changed, 66 insertions(+), 1 deletions(-)
---
diff --git a/konkretcmpi-0.8.7-fix-same-enum-values.patch b/konkretcmpi-0.8.7-fix-same-enum-values.patch
new file mode 100644
index 0000000..603599e
--- /dev/null
+++ b/konkretcmpi-0.8.7-fix-same-enum-values.patch
@@ -0,0 +1,59 @@
+diff -up konkretcmpi-0.8.7/src/program/main.cpp.fix-same-enum-values konkretcmpi-0.8.7/src/program/main.cpp
+--- konkretcmpi-0.8.7/src/program/main.cpp.fix-same-enum-values 2012-08-06 09:59:40.305815835 +0200
++++ konkretcmpi-0.8.7/src/program/main.cpp 2012-08-06 10:00:04.859436302 +0200
+@@ -36,6 +36,7 @@
+ #include <cassert>
+ #include <cstdarg>
+ #include <map>
++#include <set>
+ #include <cassert>
+ #include <unistd.h>
+
+@@ -1665,6 +1666,7 @@ static void gen_enums(
+ value_map.push_back(tmp);
+ }
+
++ set<string> names;
+ if (values.size())
+ {
+ put(os, "typedef enum _$0_$1_Enum\n", sn, pn, NULL);
+@@ -1678,6 +1680,14 @@ static void gen_enums(
+ char buf[32];
+ sprintf(buf, "%ld", x);
+
++ // Name must be unique
++ string nvn_ = nvn;
++ if (names.find(nvn_) != names.end()) {
++ nvn_ = nvn + "_" + buf;
++ }
++ names.insert(nvn_);
++ nvn = nvn_;
++
+ put(os, " $0_$1_$3 = $4,\n",
+ sn, pn, vn, nvn.c_str(), buf, NULL);
+ }
+@@ -1688,14 +1698,24 @@ static void gen_enums(
+
+ // Generate enuemrated setters:
+
++ names.clear();
+ for (size_t i = 0; i < values.size(); i++)
+ {
+ const char* vn = values[i].c_str();
+ string nvn = normalize_value_qual_name(vn);
++
+ long x = i < value_map.size() ? value_map[i] : 0;
+ char buf[32];
+ sprintf(buf, "%ld", x);
+
++ // Name must be unique
++ string nvn_ = nvn;
++ if (names.find(nvn_) != names.end()) {
++ nvn_ = nvn + "_" + buf;
++ }
++ names.insert(nvn_);
++ nvn = nvn_;
++
+ // $0 = sn
+ // $1 = pn
+ // $2 = nvn
diff --git a/konkretcmpi.spec b/konkretcmpi.spec
index 8373cc0..db472ce 100644
--- a/konkretcmpi.spec
+++ b/konkretcmpi.spec
@@ -1,6 +1,6 @@
Name: konkretcmpi
Version: 0.8.7
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: Tool for rapid CMPI providers development
License: MIT
@@ -15,6 +15,8 @@ Patch1: konkretcmpi-0.8.7-fix-assert.patch
Patch2: konkretcmpi-0.8.7-shared-lib.patch
# Disable check in MOF that fails with current (experimental) cim-schema
Patch3: konkretcmpi-0.8.7-fix-for-current-schema.patch
+# Schema sometimes has same Value for more keys in ValueMap
+Patch4: konkretcmpi-0.8.7-fix-same-enum-values.patch
BuildRequires: sblim-cmpi-devel
@@ -37,6 +39,7 @@ This package provides required files for development using konkretcmpi.
%patch1 -p1 -b .fix-assert
%patch2 -p1 -b .shared-lib
%patch3 -p1 -b .fix-for-current-schema
+%patch4 -p1 -b .fix-same-enum-values
%build
%configure --enable-static=no
@@ -66,6 +69,9 @@ rm -rf $RPM_BUILD_ROOT/usr/lib*/libkonkret.la
%changelog
+* Mon Aug 06 2012 Radek Novacek <rnovacek at redhat.com> 0.8.7-6
+- Handle ValueMap with same Values in MOF
+
* Mon Aug 06 2012 Radek Novacek <rnovacek at redhat.com> 0.8.7-5
- Disable check in MOF that fails with current (experimental) cim-schema
More information about the scm-commits
mailing list