You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by Isaac Rose <is...@gmail.com> on 2014/11/18 23:27:46 UTC
Re: svn commit: r1640437 - in /celix/trunk/log_service:
CMakeLists.txt public/src/log_helper.c
The change " for (; i < arrayList_size(loghelper->logServices); i++)" does
not specify the initial value for the i. This is based on the assumption
that the compiler will automatically set it to zero, correct? Is that a
save assumption or is Celix only expected to be compiled with a specific
compiler with specific flags? If so where is that documented?
Isaac
On Tue, Nov 18, 2014 at 5:23 PM, <bp...@apache.org> wrote:
> Author: bpetri
> Date: Tue Nov 18 22:23:00 2014
> New Revision: 1640437
>
> URL: http://svn.apache.org/r1640437
> Log:
> CELIX-182: minor refactoring
>
> Modified:
> celix/trunk/log_service/CMakeLists.txt
> celix/trunk/log_service/public/src/log_helper.c
>
> Modified: celix/trunk/log_service/CMakeLists.txt
> URL:
> http://svn.apache.org/viewvc/celix/trunk/log_service/CMakeLists.txt?rev=1640437&r1=1640436&r2=1640437&view=diff
>
> ==============================================================================
> --- celix/trunk/log_service/CMakeLists.txt (original)
> +++ celix/trunk/log_service/CMakeLists.txt Tue Nov 18 22:23:00 2014
> @@ -38,8 +38,10 @@ if (LOG_SERVICE)
> )
>
> install_bundle(log_service
> - HEADERS
> - public/include/log_service.h
> + HEADERS
> + public/include/log_service.h
> public/include/log_helper.h
> + RESOURCES
> + public/src/log_helper.c
> )
>
> include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
>
> Modified: celix/trunk/log_service/public/src/log_helper.c
> URL:
> http://svn.apache.org/viewvc/celix/trunk/log_service/public/src/log_helper.c?rev=1640437&r1=1640436&r2=1640437&view=diff
>
> ==============================================================================
> --- celix/trunk/log_service/public/src/log_helper.c (original)
> +++ celix/trunk/log_service/public/src/log_helper.c Tue Nov 18 22:23:00
> 2014
> @@ -129,19 +129,16 @@ celix_status_t logHelper_log(log_helper_
> if (loghelper != NULL) {
> pthread_mutex_lock(&loghelper->logListLock);
>
> - if (arrayList_size(loghelper->logServices) > 0) {
> - int i = 0;
> + int i = 0;
>
> - for (; i < arrayList_size(loghelper->logServices);
> i++) {
> + for (; i < arrayList_size(loghelper->logServices); i++) {
>
> - log_service_pt logService =
> arrayList_get(loghelper->logServices, i);
> + log_service_pt logService =
> arrayList_get(loghelper->logServices, i);
>
> - if (logService != NULL) {
> -
> (logService->log)(logService->logger, level, message);
> - logged = true;
> - }
> + if (logService != NULL) {
> + (logService->log)(logService->logger,
> level, message);
> + logged = true;
> }
> -
> }
>
> pthread_mutex_unlock(&loghelper->logListLock);
>
>
>
Re: svn commit: r1640437 - in /celix/trunk/log_service:
CMakeLists.txt public/src/log_helper.c
Posted by Isaac Rose <is...@gmail.com>.
I see it and thanks for the reply.
Isaac
On Nov 19, 2014 1:18 AM, "Björn Petri" <bj...@sundevil.de> wrote:
> Hi Isaac,
>
> I didn't remove the initalization, i gets created and initialized directly
> in front of the loop.
>
> Also it actually might be unnecessary with some compilers or flags, newly
> created variables/memory should be always initialized. Otherwise it's
> probably a bug.
>
> Regards,
> Björn
>
> Sent with AquaMail for Android
> http://www.aqua-mail.com
>
>
> On November 18, 2014 11:29:47 PM Isaac Rose <is...@gmail.com> wrote:
>
> The change " for (; i < arrayList_size(loghelper->logServices); i++)"
>> does
>> not specify the initial value for the i. This is based on the assumption
>> that the compiler will automatically set it to zero, correct? Is that a
>> save assumption or is Celix only expected to be compiled with a specific
>> compiler with specific flags? If so where is that documented?
>>
>> Isaac
>>
>> On Tue, Nov 18, 2014 at 5:23 PM, <bp...@apache.org> wrote:
>>
>> > Author: bpetri
>> > Date: Tue Nov 18 22:23:00 2014
>> > New Revision: 1640437
>> >
>> > URL: http://svn.apache.org/r1640437
>> > Log:
>> > CELIX-182: minor refactoring
>> >
>> > Modified:
>> > celix/trunk/log_service/CMakeLists.txt
>> > celix/trunk/log_service/public/src/log_helper.c
>> >
>> > Modified: celix/trunk/log_service/CMakeLists.txt
>> > URL:
>> > http://svn.apache.org/viewvc/celix/trunk/log_service/
>> CMakeLists.txt?rev=1640437&r1=1640436&r2=1640437&view=diff
>> >
>> > ============================================================
>> ==================
>> > --- celix/trunk/log_service/CMakeLists.txt (original)
>> > +++ celix/trunk/log_service/CMakeLists.txt Tue Nov 18 22:23:00 2014
>> > @@ -38,8 +38,10 @@ if (LOG_SERVICE)
>> > )
>> >
>> > install_bundle(log_service
>> > - HEADERS
>> > - public/include/log_service.h
>> > + HEADERS
>> > + public/include/log_service.h
>> > public/include/log_helper.h
>> > + RESOURCES
>> > + public/src/log_helper.c
>> > )
>> >
>> > include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
>> >
>> > Modified: celix/trunk/log_service/public/src/log_helper.c
>> > URL:
>> > http://svn.apache.org/viewvc/celix/trunk/log_service/
>> public/src/log_helper.c?rev=1640437&r1=1640436&r2=1640437&view=diff
>> >
>> > ============================================================
>> ==================
>> > --- celix/trunk/log_service/public/src/log_helper.c (original)
>> > +++ celix/trunk/log_service/public/src/log_helper.c Tue Nov 18 22:23:00
>> > 2014
>> > @@ -129,19 +129,16 @@ celix_status_t logHelper_log(log_helper_
>> > if (loghelper != NULL) {
>> > pthread_mutex_lock(&loghelper->logListLock);
>> >
>> > - if (arrayList_size(loghelper->logServices) > 0) {
>> > - int i = 0;
>> > + int i = 0;
>> >
>> > - for (; i < arrayList_size(loghelper->
>> logServices);
>> > i++) {
>> > + for (; i < arrayList_size(loghelper->logServices);
>> i++) {
>> >
>> > - log_service_pt logService =
>> > arrayList_get(loghelper->logServices, i);
>> > + log_service_pt logService =
>> > arrayList_get(loghelper->logServices, i);
>> >
>> > - if (logService != NULL) {
>> > -
>> > (logService->log)(logService->logger, level, message);
>> > - logged = true;
>> > - }
>> > + if (logService != NULL) {
>> > + (logService->log)(logService->logger,
>> > level, message);
>> > + logged = true;
>> > }
>> > -
>> > }
>> >
>> > pthread_mutex_unlock(&loghelper->logListLock);
>> >
>> >
>> >
>>
>
>
>
Re: svn commit: r1640437 - in /celix/trunk/log_service: CMakeLists.txt public/src/log_helper.c
Posted by Björn Petri <bj...@sundevil.de>.
Hi Isaac,
I didn't remove the initalization, i gets created and initialized directly
in front of the loop.
Also it actually might be unnecessary with some compilers or flags, newly
created variables/memory should be always initialized. Otherwise it's
probably a bug.
Regards,
Björn
Sent with AquaMail for Android
http://www.aqua-mail.com
On November 18, 2014 11:29:47 PM Isaac Rose <is...@gmail.com> wrote:
> The change " for (; i < arrayList_size(loghelper->logServices); i++)" does
> not specify the initial value for the i. This is based on the assumption
> that the compiler will automatically set it to zero, correct? Is that a
> save assumption or is Celix only expected to be compiled with a specific
> compiler with specific flags? If so where is that documented?
>
> Isaac
>
> On Tue, Nov 18, 2014 at 5:23 PM, <bp...@apache.org> wrote:
>
> > Author: bpetri
> > Date: Tue Nov 18 22:23:00 2014
> > New Revision: 1640437
> >
> > URL: http://svn.apache.org/r1640437
> > Log:
> > CELIX-182: minor refactoring
> >
> > Modified:
> > celix/trunk/log_service/CMakeLists.txt
> > celix/trunk/log_service/public/src/log_helper.c
> >
> > Modified: celix/trunk/log_service/CMakeLists.txt
> > URL:
> >
> http://svn.apache.org/viewvc/celix/trunk/log_service/CMakeLists.txt?rev=1640437&r1=1640436&r2=1640437&view=diff
> >
> >
> ==============================================================================
> > --- celix/trunk/log_service/CMakeLists.txt (original)
> > +++ celix/trunk/log_service/CMakeLists.txt Tue Nov 18 22:23:00 2014
> > @@ -38,8 +38,10 @@ if (LOG_SERVICE)
> > )
> >
> > install_bundle(log_service
> > - HEADERS
> > - public/include/log_service.h
> > + HEADERS
> > + public/include/log_service.h
> > public/include/log_helper.h
> > + RESOURCES
> > + public/src/log_helper.c
> > )
> >
> > include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
> >
> > Modified: celix/trunk/log_service/public/src/log_helper.c
> > URL:
> >
> http://svn.apache.org/viewvc/celix/trunk/log_service/public/src/log_helper.c?rev=1640437&r1=1640436&r2=1640437&view=diff
> >
> >
> ==============================================================================
> > --- celix/trunk/log_service/public/src/log_helper.c (original)
> > +++ celix/trunk/log_service/public/src/log_helper.c Tue Nov 18 22:23:00
> > 2014
> > @@ -129,19 +129,16 @@ celix_status_t logHelper_log(log_helper_
> > if (loghelper != NULL) {
> > pthread_mutex_lock(&loghelper->logListLock);
> >
> > - if (arrayList_size(loghelper->logServices) > 0) {
> > - int i = 0;
> > + int i = 0;
> >
> > - for (; i < arrayList_size(loghelper->logServices);
> > i++) {
> > + for (; i < arrayList_size(loghelper->logServices); i++) {
> >
> > - log_service_pt logService =
> > arrayList_get(loghelper->logServices, i);
> > + log_service_pt logService =
> > arrayList_get(loghelper->logServices, i);
> >
> > - if (logService != NULL) {
> > -
> > (logService->log)(logService->logger, level, message);
> > - logged = true;
> > - }
> > + if (logService != NULL) {
> > + (logService->log)(logService->logger,
> > level, message);
> > + logged = true;
> > }
> > -
> > }
> >
> > pthread_mutex_unlock(&loghelper->logListLock);
> >
> >
> >