pnoltes commented on a change in pull request #392:
URL: https://github.com/apache/celix/pull/392#discussion_r790316756
##########
File path: libs/framework/src/service_tracker.c
##########
@@ -94,11 +94,9 @@ celix_status_t serviceTracker_create(bundle_context_pt
context, const char * ser
if (service == NULL || *tracker != NULL) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
- if (status == CELIX_SUCCESS) {
- char filter[512];
- snprintf(filter, sizeof(filter), "(%s=%s)",
OSGI_FRAMEWORK_OBJECTCLASS, service);
- serviceTracker_createWithFilter(context, filter, customizer,
tracker);
- }
+ char filter[512];
+ snprintf(filter, sizeof(filter), "(%s=%s)",
OSGI_FRAMEWORK_OBJECTCLASS, service);
Review comment:
While update this, maybe also use `asprintf` to prevent the situation
that 512 char are not enough for the filter.
##########
File path: libs/framework/src/service_tracker.c
##########
@@ -354,31 +337,20 @@ static void serviceTracker_serviceChanged(void *handle,
celix_service_event_t *e
}
celixThreadMutex_unlock(&tracker->closeSync.mutex);
- if (!closing) {
- switch (event->type) {
- case OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED:
- serviceTracker_track(tracker, event->reference, event);
- break;
- case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED:
+ switch (event->type) {
+ case OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED:
+ case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED:
+ if(!closing)
Review comment:
Please add `{` `}` for the if statement
##########
File path: CMakeLists.txt
##########
@@ -44,7 +44,7 @@ endif ()
set(ENABLE_MORE_WARNINGS OFF)
# Set C specific flags
-set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
+set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu11 -fPIC ${CMAKE_C_FLAGS}")
Review comment:
Note: that this will update the C requirements for Celix from gnu99 to
gnu11.
I have no issue with this, but maybe it good to get some broader feedback on
this.
@rlenferink , @rbulter , @ErjanAltena and @stegemr Do any of you have any
uses updating the Celix C standard from gnu99 to gnu11? . Of I we have no
issue, can we also introduce the use of `#pragma once` for C code?
##########
File path: libs/framework/src/bundle_context.c
##########
@@ -76,7 +76,7 @@ celix_status_t bundleContext_create(framework_pt framework,
celix_framework_logg
}
}
-
+ //FIXME: context == NULL?
Review comment:
In earlier Celix code we tested whether malloc (and calloc) returns a
not NULL value.
In recent code we opted not to check this anymore. For a few reasons:
- malloc can and will return a (virtual) pointer even if there not enough
memory.
- Testing of for the "out of memory" iflelse branch is not really doable,
resulting in lower test coverage and untested code
- For a modern OS the OOM killer will stop the process, in that case there
is no need to handle OOM situations.
##########
File path: libs/utils/include/celix_build_assert.h
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef CELIX_CELIX_BUILD_ASSERT_H
+#define CELIX_CELIX_BUILD_ASSERT_H
+
+#define BUILD_ASSERT(cond) \
Review comment:
Yeah for newer code I always prefer a `CELIX_` / `celix_` prefix
##########
File path: libs/utils/include/celix_ref.h
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef CELIX_CELIX_REF_H
+#define CELIX_CELIX_REF_H
+
+#include <stdatomic.h>
+#include <limits.h>
+#include <assert.h>
+
+struct celix_ref {
+ atomic_int count;
+};
+
+static inline void celix_ref_init(struct celix_ref *ref) {
Review comment:
I would prefer some doxygen documentation explaining the functions from
a users perspective
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]