Skip to content

Commit f50ad91

Browse files
committed
build errors
1 parent 961c2b9 commit f50ad91

3 files changed

Lines changed: 796 additions & 746 deletions

File tree

src/libltfs/arch/ltfs_arch_ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ extern "C" {
7474
} \
7575
}while(0)
7676

77-
inline void arch_strcpy_limited(char *dest, const char *src, int count)
77+
static inline void arch_strcpy_limited(char *dest, const char *src, int count)
7878
{
7979
int i;
8080
for (i = 0; i < (count) && (src)[i] != '\0'; i++) {

src/libltfs/ltfslogging.c

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@
4949
#include "arch/win/win_util.h"
5050
#include <windows.h>
5151
#endif
52-
5352
#include <stdlib.h>
5453
#include <stdarg.h>
5554
#include <string.h>
5655
#include <errno.h>
57-
5856
#ifndef mingw_PLATFORM
5957
#include <syslog.h>
6058
#endif
@@ -77,20 +75,21 @@
7775
#include <sys/types.h>
7876
#include <sys/stat.h>
7977
#include <fcntl.h>
78+
#include <unistd.h>
8079
#include "arch/win/winlog.h"
8180
#else
8281
#include <dlfcn.h>
8382
#include <sys/types.h>
8483
#endif
85-
#include <unistd.h>
84+
8685
#include "libltfs/ltfslogging.h"
8786
#include "libltfs/ltfs_thread.h"
8887
#include "libltfs/ltfs_locking.h"
8988
#include "libltfs/ltfs_error.h"
9089
#include "queue.h"
9190
#include "ltfssnmp.h"
9291

93-
/* Some hard-coded message bits. */
92+
/* Some hard-coded message bits. */
9493
#define MSG_PREFIX_POSIX_TID "%016llx LTFS%s "
9594
#define MSG_PREFIX_TID "%lx LTFS%s "
9695
#define MSG_PREFIX "LTFS%s "
@@ -102,8 +101,8 @@ struct plugin_bundle {
102101
TAILQ_ENTRY(plugin_bundle) list;
103102
int32_t start_id; /**< First message ID allocated to this plugin */
104103
int32_t end_id; /**< Last message ID allocated to this plugin */
105-
UResourceBundle *bundle_root; /**< Root resource bundle for this plugin */
106-
UResourceBundle *bundle_messages; /**< Resource bundle containing this plugin's messages */
104+
UResourceBundle* bundle_root; /**< Root resource bundle for this plugin */
105+
UResourceBundle* bundle_messages; /**< Resource bundle containing this plugin's messages */
107106
};
108107

109108
/* Syslog levels corresponding to the LTFS logging levels defined in libltfs/ltfslogging.h. */
@@ -119,9 +118,9 @@ static int syslog_levels[] = {
119118
};
120119

121120
#ifdef mingw_PLATFORM
122-
char *libltfs_dat;
123-
char *internal_error_dat;
124-
char *tape_common_dat;
121+
char* libltfs_dat;
122+
char* internal_error_dat;
123+
char* tape_common_dat;
125124
#else
126125
U_CFUNC char libltfs_dat[]; /* U_CFUNC is an ICU synonym for extern. */
127126
U_CFUNC char internal_error_dat[]; /* U_CFUNC is an ICU synonym for extern. */
@@ -135,23 +134,23 @@ bool ltfs_print_thread_id = false;
135134
static bool ltfs_use_syslog = false;
136135

137136
/* Resource bundles, used for quick indexing into message arrays. */
138-
static UResourceBundle *bundle_fallback;
137+
static UResourceBundle* bundle_fallback;
139138
static TAILQ_HEAD(message_struct, plugin_bundle) plugin_bundles;
140139

141140
/* Static output buffer: needed to avoid allocating memory on error. */
142141
static ltfs_mutex_t output_lock;
143142
static char output_buf[OUTPUT_BUF_SIZE];
144143
static char msg_buf[OUTPUT_BUF_SIZE * 2];
145-
static UConverter *output_conv = NULL;
144+
static UConverter* output_conv = NULL;
146145

147146
#ifdef mingw_PLATFORM
148-
static int _open_message_file(char *bundle_name, void **bundle_data);
147+
static int _open_message_file(char* bundle_name, void** bundle_data);
149148
#endif
150149
int ltfsprintf_init(int log_level, bool use_syslog, bool print_thread_id)
151150
{
152151
int ret;
153152
UErrorCode err = U_ZERO_ERROR;
154-
struct plugin_bundle *pl;
153+
struct plugin_bundle* pl;
155154

156155
/* Open converter for generating output in the system locale. */
157156
ret = ltfs_mutex_init(&output_lock);
@@ -174,7 +173,7 @@ int ltfsprintf_init(int log_level, bool use_syslog, bool print_thread_id)
174173
#endif
175174

176175
/* Load the libltfs message bundle and the primary message set */
177-
ret = ltfsprintf_load_plugin("libltfs", libltfs_dat, (void **)&pl);
176+
ret = ltfsprintf_load_plugin("libltfs", libltfs_dat, (void**)&pl);
178177
if (ret < 0) {
179178
fprintf(stderr, "LTFS11293E Cannot load messages for libltfs (%d)\n", ret);
180179
ltfsprintf_finish();
@@ -191,15 +190,15 @@ int ltfsprintf_init(int log_level, bool use_syslog, bool print_thread_id)
191190
}
192191

193192
/* Load the libltfs message bundle and the primary message set */
194-
ret = ltfsprintf_load_plugin("internal_error", internal_error_dat, (void **)&pl);
193+
ret = ltfsprintf_load_plugin("internal_error", internal_error_dat, (void**)&pl);
195194
if (ret < 0) {
196195
fprintf(stderr, "LTFS11293E Cannot load messages for internal error (%d)\n", ret);
197196
ltfsprintf_finish();
198197
return ret;
199198
}
200199

201200
/* Load the libltfs message bundle and the primary message set */
202-
ret = ltfsprintf_load_plugin("tape_common", tape_common_dat, (void **)&pl);
201+
ret = ltfsprintf_load_plugin("tape_common", tape_common_dat, (void**)&pl);
203202
if (ret < 0) {
204203
fprintf(stderr, "LTFS11293E Cannot load messages for tape backend common messages (%d)\n", ret);
205204
ltfsprintf_finish();
@@ -225,7 +224,7 @@ void ltfsprintf_finish()
225224
bundle_fallback = NULL;
226225
}
227226
while (1) {
228-
if (! TAILQ_EMPTY(&plugin_bundles))
227+
if (!TAILQ_EMPTY(&plugin_bundles))
229228
ltfsprintf_unload_plugin(TAILQ_LAST(&plugin_bundles, message_struct));
230229
else
231230
break;
@@ -263,11 +262,11 @@ int ltfsprintf_set_log_level(int log_level)
263262
}
264263

265264

266-
int ltfsprintf_load_plugin(const char *bundle_name, void *bundle_data, void **messages)
265+
int ltfsprintf_load_plugin(const char* bundle_name, void* bundle_data, void** messages)
267266
{
268267
UErrorCode err = U_ZERO_ERROR;
269-
UResourceBundle *bundle;
270-
struct plugin_bundle *pl;
268+
UResourceBundle* bundle;
269+
struct plugin_bundle* pl;
271270

272271
CHECK_ARG_NULL(bundle_name, -LTFS_NULL_ARG);
273272
CHECK_ARG_NULL(messages, -LTFS_NULL_ARG);
@@ -284,7 +283,7 @@ int ltfsprintf_load_plugin(const char *bundle_name, void *bundle_data, void **me
284283
#endif
285284

286285
pl = calloc(1, sizeof(struct plugin_bundle));
287-
if (! pl) {
286+
if (!pl) {
288287
if (libltfs_dat_init)
289288
ltfsmsg(LTFS_ERR, 10001E, __FUNCTION__);
290289
else
@@ -352,7 +351,8 @@ int ltfsprintf_load_plugin(const char *bundle_name, void *bundle_data, void **me
352351
pl->end_id = pl->start_id + 999;
353352
}
354353
ures_close(bundle);
355-
} else
354+
}
355+
else
356356
pl->end_id = pl->start_id + 999;
357357

358358
*messages = pl;
@@ -362,9 +362,9 @@ int ltfsprintf_load_plugin(const char *bundle_name, void *bundle_data, void **me
362362
return 0;
363363
}
364364

365-
void ltfsprintf_unload_plugin(void *handle)
365+
void ltfsprintf_unload_plugin(void* handle)
366366
{
367-
struct plugin_bundle *pl = handle;
367+
struct plugin_bundle* pl = handle;
368368

369369
if (pl) {
370370
ltfs_mutex_lock(&output_lock);
@@ -377,16 +377,16 @@ void ltfsprintf_unload_plugin(void *handle)
377377
}
378378

379379
/* Print a formatted message in the current system locale. */
380-
int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id, ...)
380+
int ltfsmsg_internal(bool print_id, int level, char** msg_out, const char* _id, ...)
381381
{
382-
const UChar *format_uc = NULL;
382+
const UChar* format_uc = NULL;
383383
int32_t prefix_len, format_len;
384384
int32_t id_val;
385385
char id[16];
386386
size_t idlen;
387387
UErrorCode err = U_ZERO_ERROR;
388388
va_list argp;
389-
struct plugin_bundle *entry;
389+
struct plugin_bundle* entry;
390390

391391
/*
392392
* We accept quoted id used in HPE backend source,
@@ -399,14 +399,15 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
399399
if (idlen > 1 && _id[0] == '"' && _id[idlen - 1] == '"') {
400400
arch_strcpy_limited(id, _id + 1, idlen - 2);
401401
id[idlen - 2] = '\0';
402-
} else {
402+
}
403+
else {
403404
arch_strcpy_auto(id, _id);
404405
}
405406

406407
id_val = atol(id);
407408

408409
/* Check loaded plugins for the message, most recently loaded first */
409-
if (! TAILQ_EMPTY(&plugin_bundles)) {
410+
if (!TAILQ_EMPTY(&plugin_bundles)) {
410411
ltfs_mutex_lock(&output_lock);
411412
TAILQ_FOREACH(entry, &plugin_bundles, list) {
412413
if (entry->start_id <= id_val && id_val <= entry->end_id) {
@@ -415,10 +416,12 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
415416
if (U_FAILURE(err) && err != U_MISSING_RESOURCE_ERROR) {
416417
ltfs_mutex_unlock(&output_lock);
417418
goto internal_error;
418-
} else if (U_SUCCESS(err))
419+
}
420+
else if (U_SUCCESS(err))
419421
break;
420422
format_uc = NULL;
421-
} else if (id[0] == 'I' || id[0] == 'D') {
423+
}
424+
else if (id[0] == 'I' || id[0] == 'D') {
422425
err = U_ZERO_ERROR;
423426
format_uc = ures_getStringByKey(entry->bundle_messages, id, &format_len, &err);
424427
if (U_SUCCESS(err))
@@ -431,7 +434,7 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
431434
}
432435

433436
/* Try to get a fallback message if we didn't find the real message */
434-
if (! format_uc) {
437+
if (!format_uc) {
435438
format_uc = ures_getStringByKey(bundle_fallback, "notfound", &format_len, &err);
436439
if (U_FAILURE(err))
437440
goto internal_error;
@@ -459,7 +462,8 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
459462
ltfs_mutex_unlock(&output_lock);
460463
goto internal_error;
461464
}
462-
} else if (U_FAILURE(err)) {
465+
}
466+
else if (U_FAILURE(err)) {
463467
ltfs_mutex_unlock(&output_lock);
464468
goto internal_error;
465469
}
@@ -469,9 +473,10 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
469473
va_start(argp, _id);
470474
vsyslog(level, output_buf, argp);
471475
va_end(argp);
472-
}__except (EXCEPTION_EXECUTE_HANDLER) {
476+
}
477+
__except (EXCEPTION_EXECUTE_HANDLER) {
473478
EXCEPTION_POINTERS* exceptionInfo = GetExceptionInformation();
474-
fprintf(stderr,"An exception occurred when logging! Exception code: 0x%X\n", exceptionInfo->ExceptionRecord->ExceptionCode);
479+
fprintf(stderr, "An exception occurred when logging! Exception code: 0x%X\n", exceptionInfo->ExceptionRecord->ExceptionCode);
475480
}
476481
#else
477482
va_start(argp, _id);
@@ -493,7 +498,7 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
493498

494499
if (msg_out) {
495500
va_start(argp, _id);
496-
arch_vsprintf(msg_buf,sizeof(msg_buf), output_buf, argp);
501+
arch_vsprintf(msg_buf, sizeof(msg_buf), output_buf, argp);
497502
va_end(argp);
498503
*msg_out = arch_strdup(msg_buf);
499504
}
@@ -502,12 +507,12 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
502507
if (is_snmp_enabled()) {
503508
if (is_snmp_trapid(id) == true) {
504509
/* Send a trap of Info (id and pos+1) */
505-
char *pos;
510+
char* pos;
506511
va_start(argp, _id);
507-
arch_vsprintf(msg_buf,sizeof(msg_buf), output_buf, argp);
512+
arch_vsprintf(msg_buf, sizeof(msg_buf), output_buf, argp);
508513
va_end(argp);
509514
pos = strstr(msg_buf, " ");
510-
send_ltfsInfoTrap(pos+1);
515+
send_ltfsInfoTrap(pos + 1);
511516
}
512517
}
513518
#endif
@@ -530,7 +535,8 @@ int ltfsmsg_internal(bool print_id, int level, char **msg_out, const char *_id,
530535
syslog(syslog_levels[LTFS_TRACE], MSG_PREFIX_TID MSG_FALLBACK, (unsigned long)ltfs_get_thread_id(), id);
531536
else
532537
syslog(syslog_levels[level], MSG_PREFIX_TID MSG_FALLBACK, (unsigned long)ltfs_get_thread_id(), id);
533-
} else {
538+
}
539+
else {
534540
if (level <= LTFS_ERR)
535541
syslog(syslog_levels[LTFS_ERR], MSG_PREFIX MSG_FALLBACK, id);
536542
else if (level >= LTFS_TRACE)

0 commit comments

Comments
 (0)