All of lore.kernel.org
 help / color / mirror / Atom feed
From: Erik Schuitema <e.schuitema@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-core] rt_printf truncates large strings at end of buffer
Date: Thu, 03 Jun 2010 11:16:32 +0200	[thread overview]
Message-ID: <4C0772F0.2030806@domain.hid> (raw)

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

Hi all,

I experienced some undesired behavior when printing large strings (>239 
chars) with rt_printf or one of its variants.

Due to the exact implementation of rt_vfprintf, one has a problem when 
trying to print large strings when the writing position is close to the 
end of the ring buffer, no matter its size or space left.
If the space left at the end of the buffer is larger than 238 chars (= 
RT_PRINT_LINE_BREAK - 2*sizeof(struct entry_head))  (the buffer's write 
pos hasn't automatically wrapped yet) but smaller than the desired 
string length, the string is truncated without any form of feedback to 
the user.

It would be useful to return the actual number of printed characters in 
that case (now rt_vfprintf returns the result of vsnprintf(), which 
returns the number of bytes that would have been printed if there had 
been enough space).

If that conflicts with any specification, it would be nice if there 
could be at least one retry. If the string could not be printed 
completely, the incomplete entry can be modified into an empty entry, 
the writepos can be wrapped, and there can be one retry.

Right now, I have to manually cut my strings in chunks of 239 bytes 
before printing them.

Best regards,
Erik

[-- Attachment #2: Type: text/html, Size: 1617 bytes --]

                 reply	other threads:[~2010-06-03  9:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C0772F0.2030806@domain.hid \
    --to=e.schuitema@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.