This patch removes the format-truncation error. The warning is because c has size of 3, but using "%d" is not possible to store the value.
wruler.c: In function ‘paintRuler.part.0’:
wruler.c:184:28: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 3 [-Wformat-truncation=]
snprintf(c, sizeof(c), "%d", ++j);
^~
wruler.c:184:27: note: directive argument in the range [1, 2147483647]
snprintf(c, sizeof(c), "%d", ++j);
^~~~
wruler.c:184:4: note: ‘snprintf’ output between 2 and 11 bytes into a destination of size 3
snprintf(c, sizeof(c), "%d", ++j);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The value "j" is the result of "m < w". w is the result of rPtr->view->size.width - rPtr->margins.left;, and both variables are unsigned int. So the value for w is an unsigned int and m is related to i. m cannot be greater of unsigned int.
i = j = m = 0;
w = rPtr->view->size.width - rPtr->margins.left;
while (m < w) {
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fgGC, rPtr->margins.left + m, 23, rPtr->margins.left + m, marks[i % 8] + 23);
if (i != 0 && i % 8 == 0) {
snprintf(c, sizeof(c), "%hu", ++j);
WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
rPtr->font, rPtr->margins.left + 2 + m, 26, c, 2);
}
m = (++i) * 10;
}
The printf modifier should be unsigned int.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
It looks like the original code was expecting the side effect of specifying
a length in the %d to smartly truncate the number, which it does not.
The new code has the same behaviour without extra complexity.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
WINGs dispatches window resize events using callback functions, which
means having a fixed argument list for that function.
It is then correct to not use all the arguments, so this patch adds the
appropriate stuff to avoid a false report from compiler.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This reverts commit f4890b17e6.
It turns out that I needed some functions from wtext.c to develop
a WINGs front-end to my comic book collection MySQL database.
Conflicts:
WINGs/Makefile.am
WINGs/WINGs/WINGs.h
for arq in `git ls-files *.c`; do
echo $arq;
indent -linux -l115 $arq;
done
The different line break at 115 columns is because
I use a widescreen monitor :-)
are affected. Fixes for old code too.
- Double buffering in WMList. All widgets or apps using WMList and
having user drawing porcedures in place will inherit this double
buffering automatically too.
- New functions in WINGs: WMGetColorAlpha(), WMIsAAFont()
- Misc code cleanups in WINGs and src/dialog.c
WMDrawString() and WMDrawImageString() now take WMColor instead of GC as
arguments. WMDrawImageString() receives 2 colors (text & background).
This is to allow easy extension for Xft/Xrender and hide X low level details
- Added alpha channel to WMColor. 2 new functions also:
WMCreateRGBAColor() and WMSetColorAlpha()
- Miscelaneous code cleanups in wtext.c
- Removed obsoleted acconfig.h and implemented its functionality using
AC_DEFINE and AC_DEFINE_UNQUOTED as autoconf 2.5x recommends.
This will definitely enforce the need to use autoconf 2.5x
This thing is completely broken! There are functions that take a
completely different set of arguments than the ones currently used to call
them. There are even functions that are not defined anywhere but
called from wtext.c
Please fix it before re-enabling it in Makefile.am