public inbox for ecos-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf
@ 2009-06-27 11:26 bugzilla-daemon
  2009-07-02 16:01 ` [Bug 1000800] " bugzilla-daemon
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: bugzilla-daemon @ 2009-06-27 11:26 UTC (permalink / raw)
  To: ecos-bugs

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

           Summary: Diagnostics API does not include diag_vsnprintf
           Product: eCos
           Version: 3.0
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: normal
         Component: Debugging
        AssignedTo: gary@mlbassoc.com
        ReportedBy: chris@zynaptic.com
         QAContact: ecos-bugs@ecos.sourceware.org
             Class: ---


Created an attachment (id=761)
 --> (http://bugs.ecos.sourceware.org/attachment.cgi?id=761)
Adds diag_vsnprintf to the diagnostics API.

The safe version of diag_vsprintf (diag_vsnprintf) is not present in the
diagnostics API.  The attached patch adds it and also introduces compile time
warnings recommending the use of the safe sprintf variants.  YMMV as to whether
the warnings are acceptable - I can easily roll a new patch without them.


-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
@ 2009-07-02 16:01 ` bugzilla-daemon
  2010-09-13 20:00 ` bugzilla-daemon
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2009-07-02 16:01 UTC (permalink / raw)
  To: ecos-bugs

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800


Andrew Lunn <andrew.lunn@ascom.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew.lunn@ascom.ch




--- Comment #1 from Andrew Lunn <andrew.lunn@ascom.ch>  2009-07-02 17:00:58 ---
This looks O.K. to me.

How many warnings are generated from sprintf and friends when building all the
eCos tests with this patch in place?


-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
  2009-07-02 16:01 ` [Bug 1000800] " bugzilla-daemon
@ 2010-09-13 20:00 ` bugzilla-daemon
  2010-11-20 13:32 ` bugzilla-daemon
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-09-13 20:00 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

Chris Holgate <chris@zynaptic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #761 is|0                           |1
           obsolete|                            |

--- Comment #3 from Chris Holgate <chris@zynaptic.com> 2010-09-13 21:00:49 BST ---
Created an attachment (id=977)
 --> (http://bugs.ecos.sourceware.org/attachment.cgi?id=977)
Modified patch without additional warnings.

The initial patch included warning generation when unchecked diag_xprintf calls
were used - the modified patch removes these warnings and is a straightforward
addition of the vsnprintf variant.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
  2009-07-02 16:01 ` [Bug 1000800] " bugzilla-daemon
  2010-09-13 20:00 ` bugzilla-daemon
@ 2010-11-20 13:32 ` bugzilla-daemon
  2010-11-20 14:18 ` bugzilla-daemon
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-20 13:32 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

--- Comment #4 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-20 13:32:15 GMT ---
New patch does not add additional warnings anymore (build tested for PC
and ARM arch). Note: your diff has *~ extras.

It seems for me that we should have a companion test for new INFRA function
(something like diag_snprintf1.c). 1) to know that new one exists; 2) to know
that it does not fail.

RFC: Would that be clone of diag_sprintf1.c or test case should cover and
buffer barrier checks?

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (2 preceding siblings ...)
  2010-11-20 13:32 ` bugzilla-daemon
@ 2010-11-20 14:18 ` bugzilla-daemon
  2010-11-20 18:49 ` bugzilla-daemon
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-20 14:18 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

Sergei Gavrikov <sergei.gavrikov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sergei.gavrikov@gmail.com
           Severity|normal                      |enhancement

--- Comment #5 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-20 14:17:58 GMT ---
Changed severity, CC list.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (3 preceding siblings ...)
  2010-11-20 14:18 ` bugzilla-daemon
@ 2010-11-20 18:49 ` bugzilla-daemon
  2010-11-20 18:59 ` bugzilla-daemon
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-20 18:49 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

Jonathan Larmour <jifl@ecoscentric.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jifl@ecoscentric.com

--- Comment #6 from Jonathan Larmour <jifl@ecoscentric.com> 2010-11-20 18:49:16 GMT ---
The patch doesn't actually include the ~ files, so that's no problem. 

I think just extending the existing diag_sprintf1 test would be sufficient, but
just what's easiest is best. The edge cases are most relevant to test, i.e.
n=0, n=string length-1, n=string length, n=string length+1.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (4 preceding siblings ...)
  2010-11-20 18:49 ` bugzilla-daemon
@ 2010-11-20 18:59 ` bugzilla-daemon
  2010-11-20 22:48 ` bugzilla-daemon
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-20 18:59 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

--- Comment #7 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-20 18:59:12 GMT ---
Jifl, thank you for your comment. Then I will add a few checks to
diag_sprintf1.c.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (5 preceding siblings ...)
  2010-11-20 18:59 ` bugzilla-daemon
@ 2010-11-20 22:48 ` bugzilla-daemon
  2010-11-21  7:32 ` bugzilla-daemon
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-20 22:48 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

--- Comment #8 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-20 22:48:44 GMT ---
Hm. Puzzle. Such a test will pass without an assertion fail if I compile it
using host GCC.

#include <stdio.h>
#include <assert.h>
#include <string.h>
#define STRING10 "1234567890"
int main(void) {
    char x[100];
    int ret=0;
    ret+=snprintf(NULL, 0, "%s", STRING10);
    ret+=snprintf(x, 0, "%s", STRING10);
    ret+=snprintf(x, 10, "%s", STRING10);
    ret+=snprintf(x, 10-1, "%s", STRING10);
    ret+=snprintf(x, 10+1, "%s", STRING10);
    assert(ret==10+10+10+10+10);
    return (0);
}

% for arg in -std=c99 -std=c89 -std=gnu99 -D_BSD_SOURCE
> do
> cc $arg test.c && ./a.out
> done
%

% man snprintf ;# keyphrase: which would have been written...

But, diag_snprintf() won't pass the same sequences. I should write something
like the below

// N-room tests
ret = diag_snprintf(x, 0, "%s", "1234567890");
CYG_TEST_PASS_FAIL(0==my_strlen(x), "n=0 test");
CYG_TEST_PASS_FAIL(ret==0, "n=0 test return code");

ret = diag_snprintf(x, 10, "%s", "1234567890");
CYG_TEST_PASS_FAIL(0==my_strcmp(x, "123456789"), "n=L test");
CYG_TEST_PASS_FAIL(ret==9, "n=L test return code");

ret = diag_snprintf(x, 10-1, "%s", "1234567890");
CYG_TEST_PASS_FAIL(0==my_strcmp(x,"12345678"), "n=L-1 test");
CYG_TEST_PASS_FAIL(ret==8, "n=L-1 test return code");

ret = diag_snprintf(x, 10+1, "%s", "1234567890");
CYG_TEST_PASS_FAIL(0==my_strcmp(x,"1234567890"), "n=L+1 test");
CYG_TEST_PASS_FAIL(ret==10, "n=L+1 test return code");

I  dislike it. Comments?

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (6 preceding siblings ...)
  2010-11-20 22:48 ` bugzilla-daemon
@ 2010-11-21  7:32 ` bugzilla-daemon
  2010-11-21 11:29 ` bugzilla-daemon
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-21  7:32 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

--- Comment #9 from Jonathan Larmour <jifl@ecoscentric.com> 2010-11-21 05:29:20 GMT ---
libc's snprintf is correct for ISO C99. Before C99, yes what you said would be
right that the way most people implemented snprintf would mean snprintf's
return value behaved similarly to sprintf's. But C99 changed things somewhat
and said the return value would be the number of characters that would have
been written if the 'n' argument was large enough. So you can detect a
truncated write if the returned value is >= n.

But diag_snprintf does not have to meet ISO C criteria - it's our own function
and it is more important that it be simple. That said, it would be probably be
wise to add a comment beside its prototype in diag.h noting this difference.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (7 preceding siblings ...)
  2010-11-21  7:32 ` bugzilla-daemon
@ 2010-11-21 11:29 ` bugzilla-daemon
  2010-11-21 11:31 ` bugzilla-daemon
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-21 11:29 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

--- Comment #10 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-21 11:22:21 GMT ---
Created an attachment (id=1023)
 --> (http://bugs.ecos.sourceware.org/attachment.cgi?id=1023)
/home/sg/Desktop/diag_vsnprintf_20101121.patch

diag_vsnprintf (Add CL entry)

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (8 preceding siblings ...)
  2010-11-21 11:29 ` bugzilla-daemon
@ 2010-11-21 11:31 ` bugzilla-daemon
  2010-11-21 11:59 ` bugzilla-daemon
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-21 11:31 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

Sergei Gavrikov <sergei.gavrikov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #1023|/home/sg/Desktop/diag_vsnpr |diag_vsnprintf_20101121.pat
        description|intf_20101121.patch         |ch

--- Comment #11 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-21 11:29:47 GMT ---
(From update of attachment 1023)
This patch is ready to check-in in AnonCVS. I have a patch for diag_snprint1.c
test, but, it's more reasonable to get new Bugzilla entry for it.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (10 preceding siblings ...)
  2010-11-21 11:59 ` bugzilla-daemon
@ 2010-11-21 11:59 ` bugzilla-daemon
  2010-11-24 19:03 ` bugzilla-daemon
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-21 11:59 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

Sergei Gavrikov <sergei.gavrikov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #977 is|0                           |1
           obsolete|                            |

--- Comment #12 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-21 11:31:00 GMT ---
(From update of attachment 977)
Mark as obsolete.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (9 preceding siblings ...)
  2010-11-21 11:31 ` bugzilla-daemon
@ 2010-11-21 11:59 ` bugzilla-daemon
  2010-11-21 11:59 ` bugzilla-daemon
  2010-11-24 19:03 ` bugzilla-daemon
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-21 11:59 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

--- Comment #13 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-21 11:58:53 GMT ---
Now in CVS. Mark bug as RESOLVED. Chris, thank you for your contribution.
Jonathan, thank you for time and guide.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug 1000800] Diagnostics API does not include diag_vsnprintf
  2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
                   ` (11 preceding siblings ...)
  2010-11-21 11:59 ` bugzilla-daemon
@ 2010-11-24 19:03 ` bugzilla-daemon
  12 siblings, 0 replies; 14+ messages in thread
From: bugzilla-daemon @ 2010-11-24 19:03 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000800

Sergei Gavrikov <sergei.gavrikov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |CURRENTRELEASE

--- Comment #14 from Sergei Gavrikov <sergei.gavrikov@gmail.com> 2010-11-24 18:58:30 GMT ---
Now RESOLVED.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-11-24 18:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-27 11:26 [Bug 1000800] New: Diagnostics API does not include diag_vsnprintf bugzilla-daemon
2009-07-02 16:01 ` [Bug 1000800] " bugzilla-daemon
2010-09-13 20:00 ` bugzilla-daemon
2010-11-20 13:32 ` bugzilla-daemon
2010-11-20 14:18 ` bugzilla-daemon
2010-11-20 18:49 ` bugzilla-daemon
2010-11-20 18:59 ` bugzilla-daemon
2010-11-20 22:48 ` bugzilla-daemon
2010-11-21  7:32 ` bugzilla-daemon
2010-11-21 11:29 ` bugzilla-daemon
2010-11-21 11:31 ` bugzilla-daemon
2010-11-21 11:59 ` bugzilla-daemon
2010-11-21 11:59 ` bugzilla-daemon
2010-11-24 19:03 ` bugzilla-daemon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).