intel / dleyna-collabora-android

Other
4 stars 3 forks source link

Compile warnings for dLeyna-core #60

Open markdryan opened 11 years ago

markdryan commented 11 years ago
libdleyna/core/log.c: In function 'dleyna_log_init':
libdleyna/core/log.c:148:2: warning: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
libdleyna/core/log.c:148:2: warning: nested extern declaration of 'basename' [-Wnested-externs]
libdleyna/core/log.c:148:2: warning: passing argument 1 of 'openlog' makes pointer from integer without a cast [enabled by default]
/home/markus/code/private/dleyna-collabora-android/NativeLibs/toolchain-armeabi-4.6/bin/../sysroot/usr/include/syslog.h:104:13: note: expected 'char const *' but argument is of type 'int'

The problem is that the basename function cannot be found. I'm suprised this doesn't crash. Perhaps dleyna_log_init is never called in android. Anyway, I realize this needs to be fixed in dLeyna-core but I'm not sure how? Does it even make sense to call syslog functions on Android? If not, perhaps we can just disable this code for Android.

markdryan commented 11 years ago

There is a basename function in libgen.h in the ndk.

TomKeel commented 11 years ago

If you want conditional compilation for Android, test for the ANDROID symbol, as in

#ifdef __ANDROID__
#include <libgen.h>
#endif

I've also seen BIONIC used, but ANDROID is what the NDK doc says to use.

TomKeel commented 11 years ago

About syslog. You can #include and compile calls to syslog(), but I don't think they do anything -- I don't think there's any syslog daemon. There's a logcat daemon. You have to use Android-specific stuff to send traces to it. I defined myself some convenience macros for doing it:

#include <android/log.h>

#define TAG "DLeynaNative"

#define LOGD(format, ...) \
    __android_log_print(ANDROID_LOG_DEBUG, TAG, format, ##__VA_ARGS__);

#define LOGI(format, ...) \
    __android_log_print(ANDROID_LOG_INFO, TAG, format, ##__VA_ARGS__);

#define LOGW(format, ...) \
    __android_log_print(ANDROID_LOG_WARN, TAG, format, ##__VA_ARGS__);

#define LOGE(format, ...) \
    __android_log_print(ANDROID_LOG_ERROR, TAG, format, ##__VA_ARGS__);
lferrandis commented 11 years ago

Just add a new type in the logtype (0=syslog, 1=glib) Add 2 = android and just implement it in log.c Add this option to settings & configure.ac By default on adroid, configure.ac --log-type=2

On 20/09/2013 15:15, Tom Keel wrote:

About syslog. You can #include and compile calls to syslog(), but I don't think they do anything -- I don't think there's any syslog daemon. There's a logcat daemon. You have to use Android-specific stuff to send traces to it. I defined myself some convenience macros for doing it:

|#include <android/log.h>

define TAG "DLeynaNative"

define LOGD(format, ...) \

 **android_log_print(ANDROID_LOG_DEBUG, TAG, format, ##__VA_ARGS**);

define LOGI(format, ...) \

 **android_log_print(ANDROID_LOG_INFO, TAG, format, ##__VA_ARGS**);

define LOGW(format, ...) \

 **android_log_print(ANDROID_LOG_WARN, TAG, format, ##__VA_ARGS**);

define LOGE(format, ...) \

 **android_log_print(ANDROID_LOG_ERROR, TAG, format, ##__VA_ARGS**);

|

— Reply to this email directly or view it on GitHub https://github.com/01org/dleyna-collabora-android/issues/60#issuecomment-24809289.

Ludovic Ferrandis Open Source Technology Center Intel Corporation

markdryan commented 11 years ago

Just add a new type in the logtype (0=syslog, 1=glib) Add 2 = android and just implement it in log.c Add this option to settings & configure.ac By default on adroid, configure.ac --log-type=2

Agree we should do this. This way you'd get all the dLeyna logs sent to the Android logging system. We need to wait till we have PDT approval though before adding any android specific patches to dLeyna.

Perhaps we could maintain some local patches in this repo for this time being.

To summarise.

  1. Calling syslog functions won't have any affect on Android but they won't do any harm so we can leave the code the way it is.
  2. We should create a patch that redirects dLeyna logging to the android logging daemon.
  3. We should create a patch that conditionally includes libgen.h
  4. Once we have PDT approval these patches can be merged upstream