GNU bug report logs -
#7200
[PATCH] mbsalign: avoid warning with Solaris 10 cc
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Tue, 12 Oct 2010 19:31:02 UTC
Severity: normal
Tags: patch
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7200 in the body.
You can then email your comments to 7200 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#7200
; Package
coreutils
.
(Tue, 12 Oct 2010 19:31:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Tue, 12 Oct 2010 19:31:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
For the Oct. 10 snapshot Solaris 10 cc issues this warning:
"mbsalign.c", line 135: warning: initializer does not fit or is out of range: -1
This is just a warning and doesn't break anything, but it's trivial to fix:
From 879d26601a7423e847fbc566ff7cea83ec7ed4e9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Tue, 12 Oct 2010 12:31:13 -0700
Subject: [PATCH] mbsalign: avoid warning with Solaris 10 cc
* gl/lib/mbsalign.c: Include <stdint.h> for SIZE_MAX.
Use SIZE_MAX rather than (size_t) -1, to avoid warning for
"size_t x = -1" on Solaris 10 cc.
* gl/modules/mbsalign (Depends-on): Add stdint.
---
gl/lib/mbsalign.c | 9 +++++----
gl/modules/mbsalign | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/gl/lib/mbsalign.c b/gl/lib/mbsalign.c
index 117e4bf..d588432 100644
--- a/gl/lib/mbsalign.c
+++ b/gl/lib/mbsalign.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <wchar.h>
@@ -124,7 +125,7 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
Return the length in bytes required for the final result, not counting
the trailing NUL. A return value of DEST_SIZE or larger means there
wasn't enough space. DEST will be NUL terminated in any case.
- Return (size_t) -1 upon error (invalid multi-byte sequence in SRC,
+ Return SIZE_MAX upon error (invalid multi-byte sequence in SRC,
or malloc failure), unless MBA_UNIBYTE_FALLBACK is specified.
Update *WIDTH to indicate how many columns were used before padding. */
@@ -132,7 +133,7 @@ size_t
mbsalign (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
{
- size_t ret = -1;
+ size_t ret = SIZE_MAX;
size_t src_size = strlen (src) + 1;
char *newstr = NULL;
wchar_t *str_wc = NULL;
@@ -149,7 +150,7 @@ mbsalign (const char *src, char *dest, size_t dest_size,
if (MB_CUR_MAX > 1)
{
size_t src_chars = mbstowcs (NULL, src, 0);
- if (src_chars == (size_t) -1)
+ if (src_chars == SIZE_MAX)
{
if (flags & MBA_UNIBYTE_FALLBACK)
goto mbsalign_unibyte;
@@ -277,7 +278,7 @@ ambsalign (const char *src, size_t *width, mbs_align_t align, int flags)
buf = nbuf;
*width = orig_width;
req = mbsalign (src, buf, size, width, align, flags);
- if (req == (size_t) -1)
+ if (req == SIZE_MAX)
{
free (buf);
buf = NULL;
diff --git a/gl/modules/mbsalign b/gl/modules/mbsalign
index 9d923b2..7f9c974 100644
--- a/gl/modules/mbsalign
+++ b/gl/modules/mbsalign
@@ -10,6 +10,7 @@ wchar
wctype
wcwidth
mempcpy
+stdint
configure.ac:
--
1.7.2
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#7200
; Package
coreutils
.
(Tue, 12 Oct 2010 19:55:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 7200 <at> debbugs.gnu.org (full text, mbox):
Paul Eggert wrote:
> For the Oct. 10 snapshot Solaris 10 cc issues this warning:
>
> "mbsalign.c", line 135: warning: initializer does not fit or is out of range: -1
>
> This is just a warning and doesn't break anything, but it's trivial to fix:
This too looks safe enough.
Feel free to push that.
> Subject: [PATCH] mbsalign: avoid warning with Solaris 10 cc
>
> * gl/lib/mbsalign.c: Include <stdint.h> for SIZE_MAX.
> Use SIZE_MAX rather than (size_t) -1, to avoid warning for
> "size_t x = -1" on Solaris 10 cc.
> * gl/modules/mbsalign (Depends-on): Add stdint.
Reply sent
to
Jim Meyering <jim <at> meyering.net>
:
You have taken responsibility.
(Sun, 17 Apr 2011 08:58:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
bug acknowledged by developer.
(Sun, 17 Apr 2011 08:58:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 7200-done <at> debbugs.gnu.org (full text, mbox):
Jim Meyering wrote:
> Paul Eggert wrote:
>> For the Oct. 10 snapshot Solaris 10 cc issues this warning:
>>
>> "mbsalign.c", line 135: warning: initializer does not fit or is out of range: -1
>>
>> This is just a warning and doesn't break anything, but it's trivial to fix:
>
> This too looks safe enough.
> Feel free to push that.
>
>> Subject: [PATCH] mbsalign: avoid warning with Solaris 10 cc
>>
>> * gl/lib/mbsalign.c: Include <stdint.h> for SIZE_MAX.
>> Use SIZE_MAX rather than (size_t) -1, to avoid warning for
>> "size_t x = -1" on Solaris 10 cc.
>> * gl/modules/mbsalign (Depends-on): Add stdint.
Patched 6 months ago. Closing.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 15 May 2011 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 97 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.