Skip to content

Commit 2b1ed4b

Browse files
committed
fix(log): remove remaining format specifiers and fix malformed log calls
- src/libipc/platform/posix/condition.h: * Replace all %d and %s format specifiers with stream-based syntax * Update log.error() calls to use proper streaming (e.g., "[", eno, "]") - src/libipc/platform/posix/semaphore_impl.h: * Remove %d format specifiers from log.error() calls * Fix malformed parentheses (e.g., .c_str(, "")) * Remove unnecessary empty string arguments * Use stream-based logging consistently - src/libipc/platform/win/mutex.h: * Fix malformed GetLastError() parentheses * Remove %lu format specifier, use explicit cast instead * Update to stream-based logging syntax - src/libipc/platform/win/semaphore.h: * Fix malformed GetLastError() parentheses * Remove %lu format specifier, use explicit cast instead * Update to stream-based logging syntax All format specifiers (%d, %s, %zd, %p, %lu) have been removed and replaced with proper C++ stream-based logging that is type-safe and consistent with the new imp/log interface.
1 parent 1664526 commit 2b1ed4b

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/libipc/platform/posix/condition.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class condition {
2323
pthread_cond_t *acquire_cond(char const *name) {
2424
LIBIPC_LOG();
2525
if (!shm_.acquire(name, sizeof(pthread_cond_t))) {
26-
log.error("[acquire_cond] fail shm.acquire: %s", name);
26+
log.error("[acquire_cond] fail shm.acquire: ", name);
2727
return nullptr;
2828
}
2929
return static_cast<pthread_cond_t *>(shm_.get());
@@ -62,17 +62,17 @@ class condition {
6262
int eno;
6363
pthread_condattr_t cond_attr;
6464
if ((eno = ::pthread_condattr_init(&cond_attr)) != 0) {
65-
log.error("fail pthread_condattr_init[%d]", eno);
65+
log.error("fail pthread_condattr_init[", eno, "]");
6666
return false;
6767
}
6868
LIBIPC_UNUSED auto guard_cond_attr = guard([&cond_attr] { ::pthread_condattr_destroy(&cond_attr); });
6969
if ((eno = ::pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED)) != 0) {
70-
log.error("fail pthread_condattr_setpshared[%d]", eno);
70+
log.error("fail pthread_condattr_setpshared[", eno, "]");
7171
return false;
7272
}
7373
*cond_ = PTHREAD_COND_INITIALIZER;
7474
if ((eno = ::pthread_cond_init(cond_, &cond_attr)) != 0) {
75-
log.error("fail pthread_cond_init[%d]", eno);
75+
log.error("fail pthread_cond_init[", eno, "]");
7676
return false;
7777
}
7878
finally.dismiss();
@@ -84,7 +84,7 @@ class condition {
8484
if ((shm_.ref() <= 1) && cond_ != nullptr) {
8585
int eno;
8686
if ((eno = ::pthread_cond_destroy(cond_)) != 0) {
87-
log.error("fail pthread_cond_destroy[%d]", eno);
87+
log.error("fail pthread_cond_destroy[", eno, "]");
8888
}
8989
}
9090
shm_.release();
@@ -95,7 +95,7 @@ class condition {
9595
if ((shm_.ref() <= 1) && cond_ != nullptr) {
9696
int eno;
9797
if ((eno = ::pthread_cond_destroy(cond_)) != 0) {
98-
log.error("fail pthread_cond_destroy[%d]", eno);
98+
log.error("fail pthread_cond_destroy[", eno, "]");
9999
}
100100
}
101101
shm_.clear(); // Make sure the storage is cleaned up.
@@ -113,7 +113,7 @@ class condition {
113113
case invalid_value: {
114114
int eno;
115115
if ((eno = ::pthread_cond_wait(cond_, static_cast<pthread_mutex_t *>(mtx.native()))) != 0) {
116-
log.error("fail pthread_cond_wait[%d]", eno);
116+
log.error("fail pthread_cond_wait[", eno, "]");
117117
return false;
118118
}
119119
}
@@ -137,7 +137,7 @@ class condition {
137137
if (!valid()) return false;
138138
int eno;
139139
if ((eno = ::pthread_cond_signal(cond_)) != 0) {
140-
log.error("fail pthread_cond_signal[%d]", eno);
140+
log.error("fail pthread_cond_signal[", eno, "]");
141141
return false;
142142
}
143143
return true;
@@ -147,7 +147,7 @@ class condition {
147147
if (!valid()) return false;
148148
int eno;
149149
if ((eno = ::pthread_cond_broadcast(cond_)) != 0) {
150-
log.error("fail pthread_cond_broadcast[%d]", eno);
150+
log.error("fail pthread_cond_broadcast[", eno, "]");
151151
return false;
152152
}
153153
return true;

src/libipc/platform/posix/semaphore_impl.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class semaphore {
3737
LIBIPC_LOG();
3838
close();
3939
if (!shm_.acquire(name, 1)) {
40-
log.error("[open_semaphore] fail shm.acquire: ", name, "");
40+
log.error("[open_semaphore] fail shm.acquire: ", name);
4141
return false;
4242
}
4343
// POSIX semaphore names must start with "/" on some platforms (e.g., FreeBSD)
@@ -49,7 +49,7 @@ class semaphore {
4949
}
5050
h_ = ::sem_open(sem_name_.c_str(), O_CREAT, 0666, static_cast<unsigned>(count));
5151
if (h_ == SEM_FAILED) {
52-
log.error("fail sem_open[%d]: ", errno, sem_name_.c_str(, ""));
52+
log.error("fail sem_open[", errno, "]: ", sem_name_);
5353
return false;
5454
}
5555
return true;
@@ -59,13 +59,13 @@ class semaphore {
5959
LIBIPC_LOG();
6060
if (!valid()) return;
6161
if (::sem_close(h_) != 0) {
62-
log.error("fail sem_close[%d]: ", errno, "");
62+
log.error("fail sem_close[", errno, "]");
6363
}
6464
h_ = SEM_FAILED;
6565
if (!sem_name_.empty() && shm_.name() != nullptr) {
6666
if (shm_.release() <= 1) {
6767
if (::sem_unlink(sem_name_.c_str()) != 0) {
68-
log.error("fail sem_unlink[%d]: ", errno, sem_name_.c_str(, ", name: %s"));
68+
log.error("fail sem_unlink[", errno, "]: ", sem_name_);
6969
}
7070
}
7171
}
@@ -76,7 +76,7 @@ class semaphore {
7676
LIBIPC_LOG();
7777
if (valid()) {
7878
if (::sem_close(h_) != 0) {
79-
log.error("fail sem_close[%d]: ", errno, "");
79+
log.error("fail sem_close[", errno, "]");
8080
}
8181
h_ = SEM_FAILED;
8282
}
@@ -104,7 +104,7 @@ class semaphore {
104104
if (!valid()) return false;
105105
if (tm == invalid_value) {
106106
if (::sem_wait(h_) != 0) {
107-
log.error("fail sem_wait[%d]: ", errno, "");
107+
log.error("fail sem_wait[", errno, "]");
108108
return false;
109109
}
110110
} else {
@@ -124,7 +124,7 @@ class semaphore {
124124
if (!valid()) return false;
125125
for (std::uint32_t i = 0; i < count; ++i) {
126126
if (::sem_post(h_) != 0) {
127-
log.error("fail sem_post[%d]: ", errno, "");
127+
log.error("fail sem_post[", errno, "]");
128128
return false;
129129
}
130130
}

src/libipc/platform/win/mutex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class mutex {
4040
close();
4141
h_ = ::CreateMutex(detail::get_sa(), FALSE, detail::to_tchar(name).c_str());
4242
if (h_ == NULL) {
43-
log.error("fail CreateMutex[%lu]: ", ::GetLastError(, ""), name);
43+
log.error("fail CreateMutex[", static_cast<unsigned long>(::GetLastError()), "]: ", name);
4444
return false;
4545
}
4646
return true;

src/libipc/platform/win/semaphore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class semaphore {
3939
static_cast<LONG>(count), LONG_MAX,
4040
detail::to_tchar(name).c_str());
4141
if (h_ == NULL) {
42-
log.error("fail CreateSemaphore[%lu]: ", ::GetLastError(, ""), name);
42+
log.error("fail CreateSemaphore[", static_cast<unsigned long>(::GetLastError()), "]: ", name);
4343
return false;
4444
}
4545
return true;

0 commit comments

Comments
 (0)