Skip to content

Commit 5a5fafc

Browse files
committed
fix snprintf warnings for format strings
1 parent 7271c97 commit 5a5fafc

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

m3-libs/m3core/src/unix/Common/UnixC.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ int __cdecl Unix__open (const char* path, int flags, m3_mode_t mode)
111111
result = open (path, flags, (mode_t)mode);
112112
if (m3core_trace.s.open)
113113
{
114-
char* buf = (char*)alloca (256 + strlen (path));
115-
int maxlen = sizeof buf;
114+
int maxlen = (256 + strlen (path));
115+
char* buf = (char*)alloca (maxlen);
116116
int len = snprintf (buf, maxlen, "open (%s):%d\n", path, result);
117117
write (1, buf, len);
118118
}
@@ -137,8 +137,8 @@ int __cdecl Unix__creat (const char* path, m3_mode_t mode)
137137
result = creat (path, mode);
138138
if (m3core_trace.s.creat)
139139
{
140-
char* buf = (char*)alloca (256 + strlen (path));
141-
int maxlen = sizeof buf;
140+
int maxlen = (256 + strlen (path));
141+
char* buf = (char*)alloca (maxlen);
142142
int len = snprintf (buf, maxlen, "creat (%s):%d\n", path, result);
143143
write (1, buf, len);
144144
}
@@ -160,8 +160,8 @@ int __cdecl Unix__close (int fd)
160160
result = close (fd);
161161
if (m3core_trace.s.close)
162162
{
163-
char* buf = (char*)alloca (256);
164-
int maxlen = sizeof buf;
163+
int maxlen = 256;
164+
char* buf = (char*)alloca (maxlen);
165165
int len = snprintf (buf, maxlen, "close (%d):%d\n", fd, result);
166166
write (1, buf, len);
167167
}
@@ -182,8 +182,8 @@ int __cdecl Unix__chdir (const char* path)
182182
result = chdir (path);
183183
if (m3core_trace.s.chdir)
184184
{
185-
char* buf = (char*)alloca (256 + strlen (path));
186-
int maxlen = sizeof buf;
185+
int maxlen = (256 + strlen (path));
186+
char* buf = (char*)alloca (maxlen);
187187
int len = snprintf (buf, maxlen, "chdir (%s):%d\n", path, result);
188188
write (1, buf, len);
189189
}

m3-libs/m3core/src/unix/Common/UstatC.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Ustat__stat(const char* path, m3_stat_t* m3st)
7777
#ifndef _WIN32
7878
if (m3core_trace.s.stat)
7979
{
80-
char* buf = (char*)alloca (256 + strlen (path));
81-
int maxlen = sizeof buf;
80+
int maxlen = (256 + strlen (path));
81+
char* buf = (char*)alloca (maxlen);
8282
int len = snprintf (buf, maxlen, "stat (%s):mode:%X,%d\n", path, (unsigned)st.st_mode, result);
8383
write (1, buf, len);
8484
}
@@ -108,8 +108,8 @@ Ustat__fstat(int fd, m3_stat_t* m3st)
108108
#ifndef _WIN32
109109
if (m3core_trace.s.fstat)
110110
{
111-
char* buf = (char*)alloca (256);
112-
int maxlen = sizeof buf;
111+
int maxlen = 256;
112+
char* buf = (char*)alloca (maxlen);
113113
int len = snprintf (buf, maxlen, "fstat (%d):mode:%X,%d\n", fd, (unsigned)st.st_mode, result);
114114
write (1, buf, len);
115115
}

m3-libs/m3core/src/unix/Common/Uuio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Uuio__write (int fd, const void* buf, size_t n)
2323
result = write (fd, buf, n);
2424
if (m3core_trace.s.write)
2525
{
26-
char* buf = (char*)alloca (256);
27-
int maxlen = sizeof buf;
26+
int maxlen = 256;
27+
char* buf = (char*)alloca (maxlen);
2828
int len = snprintf (buf, maxlen, "write (fd:%d, buf:%p, n:%ld):%ld\n", fd, buf, (long)n, (long)result);
2929
write (1, buf, len);
3030
}

0 commit comments

Comments
 (0)