This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
ecosconfig fix
- From: Bart Veer <bartv at ecoscentric dot com>
- To: ecos-patches at ecos dot sourceware dot org
- Date: Tue, 5 Apr 2005 10:39:22 +0100 (BST)
- Subject: ecosconfig fix
This adds some sanity checking to "ecosconfig remove", making sure
that the entity being removed really is a loadable/unloadable package.
Bart
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/common/ChangeLog,v
retrieving revision 1.13
diff -u -r1.13 ChangeLog
--- ChangeLog 26 Mar 2003 17:58:12 -0000 1.13
+++ ChangeLog 5 Apr 2005 09:38:17 -0000
@@ -1,3 +1,8 @@
+2005-04-05 Bart Veer <bartv@ecoscentric.com>
+
+ * cdl_exec.cxx (cmd_remove): check that the entities being removed
+ really are packages
+
2003-03-26 Bart Veer <bartv@ecoscentric.com>
* ecosconfig.cxx: remove TRANSLATE_PATH() support, no longer
Index: cdl_exec.cxx
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/common/cdl_exec.cxx,v
retrieving revision 1.13
diff -u -r1.13 cdl_exec.cxx
--- cdl_exec.cxx 1 May 2003 12:00:51 -0000 1.13
+++ cdl_exec.cxx 5 Apr 2005 09:38:31 -0000
@@ -371,9 +372,27 @@
try {
init(true);
for (n = 0; n < cdl_packages.size (); n++) {
- if (! config->lookup (resolve_package_alias (cdl_packages [n]))) {
+ CdlNode base = config->lookup(resolve_package_alias (cdl_packages [n]));
+ if (0 == base ) {
throw CdlStringException ("Unknown package " + cdl_packages [n]);
}
+ CdlPackage pkg = dynamic_cast<CdlPackage>(base);
+ if (0 == pkg) {
+ CdlLoadable owner = base->get_owner();
+ std::string owner_name = owner ? owner->get_name() : "<unknown>";
+ CdlOption option = dynamic_cast<CdlOption>(base);
+ CdlComponent component = dynamic_cast<CdlComponent>(base);
+ CdlInterface interface = dynamic_cast<CdlInterface>(base);
+ if (0 != option) {
+ throw CdlStringException (cdl_packages [n] + " is an option within " + owner_name + ", not a loadable package");
+ } else if (0 != component) {
+ throw CdlStringException (cdl_packages [n] + " is a component of " + owner_name + ", not a loadable package");
+ } else if (0 != interface) {
+ throw CdlStringException (cdl_packages [n] + " is an interface within " + owner_name + ", not a loadable package");
+ } else {
+ throw CdlStringException (cdl_packages [n] + " is not a loadable package");
+ }
+ }
}
for (n = 0; n < cdl_packages.size (); n++) {
config->unload_package (resolve_package_alias (cdl_packages [n]));