From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: Marios Makris <marios.makris@gmail.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 1/3] Indentation and coding style fixes on /lib/str_to_bytes.c as well as /include/str_to_bytes.h
Date: Mon, 14 May 2012 15:15:49 +0800 [thread overview]
Message-ID: <4FB0B125.3020808@cn.fujitsu.com> (raw)
In-Reply-To: <1336655089-26941-1-git-send-email-marios.makris@gmail.com>
On 05/10/2012 09:04 PM, Marios Makris wrote:
> Fixed broken identation as well as replaced the old K&R
> function declarations.
>
> Signed-off-by: Marios Makris <marios.makris@gmail.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
> include/str_to_bytes.h | 6 +-
> lib/str_to_bytes.c | 162 +++++++++++++++++++++++-------------------------
> 2 files changed, 80 insertions(+), 88 deletions(-)
>
> diff --git a/include/str_to_bytes.h b/include/str_to_bytes.h
> index 977a6b1..314eb88 100644
> --- a/include/str_to_bytes.h
> +++ b/include/str_to_bytes.h
> @@ -32,8 +32,8 @@
> #ifndef _STR_TO_BYTES_
> #define _STR_TO_BYTES_
>
> -int str_to_bytes ( char * );
> -long str_to_lbytes ( char * );
> -long long str_to_llbytes( char * );
> +int str_to_bytes(char *);
> +long str_to_lbytes(char *);
> +long long str_to_llbytes(char *);
>
> #endif
> diff --git a/lib/str_to_bytes.c b/lib/str_to_bytes.c
> index 26e4897..f18291c 100644
> --- a/lib/str_to_bytes.c
> +++ b/lib/str_to_bytes.c
> @@ -67,144 +67,136 @@
> #define B_MULT UBSIZE
> #endif
>
> -
> #define K_MULT 1024 /* Kilo or 2^10 */
> #define M_MULT 1048576 /* Mega or 2^20 */
> #define G_MULT 1073741824 /* Giga or 2^30 */
> #define T_MULT 1099511627776 /* tera or 2^40 */
>
> -int
> -str_to_bytes(s)
> -char *s;
> +int str_to_bytes(char *s)
> {
> - char mult, junk;
> - int nconv;
> - float num;
> + char mult, junk;
> + int nconv;
> + float num;
>
> - nconv = sscanf(s, "%f%c%c", &num, &mult, &junk);
> - if (nconv == 0 || nconv == 3)
> - return -1;
> + nconv = sscanf(s, "%f%c%c", &num, &mult, &junk);
> + if (nconv == 0 || nconv == 3)
> + return -1;
>
> - if (nconv == 1)
> - return num;
> + if (nconv == 1)
> + return num;
>
> - switch (mult) {
> - case 'b':
> + switch (mult) {
> + case 'b':
> return (int)(num * (float)B_MULT);
> - case 'k':
> + case 'k':
> return (int)(num * (float)K_MULT);
> - case 'K':
> + case 'K':
> return (int)((num * (float)K_MULT) * sizeof(long));
> - case 'm':
> + case 'm':
> return (int)(num * (float)M_MULT);
> - case 'M':
> + case 'M':
> return (int)((num * (float)M_MULT) * sizeof(long));
> - case 'g':
> + case 'g':
> return (int)(num * (float)G_MULT);
> - case 'G':
> - return (int)((num * (float)G_MULT) * sizeof(long));
> - default:
> - return -1;
> - }
> + case 'G':
> + return (int)((num * (float)G_MULT) * sizeof(long));
> + default:
> + return -1;
> + }
> }
>
> -long
> -str_to_lbytes(s)
> -char *s;
> +long str_to_lbytes(char *s)
> {
> - char mult, junk;
> - long nconv;
> - float num;
> + char mult, junk;
> + long nconv;
> + float num;
>
> - nconv = sscanf(s, "%f%c%c", &num, &mult, &junk);
> - if (nconv == 0 || nconv == 3)
> - return -1;
> + nconv = sscanf(s, "%f%c%c", &num, &mult, &junk);
> + if (nconv == 0 || nconv == 3)
> + return -1;
>
> - if (nconv == 1)
> - return (long)num;
> + if (nconv == 1)
> + return (long)num;
>
> - switch (mult) {
> - case 'b':
> + switch (mult) {
> + case 'b':
> return (long)(num * (float)B_MULT);
> - case 'k':
> + case 'k':
> return (long)(num * (float)K_MULT);
> - case 'K':
> + case 'K':
> return (long)((num * (float)K_MULT) * sizeof(long));
> - case 'm':
> + case 'm':
> return (long)(num * (float)M_MULT);
> - case 'M':
> + case 'M':
> return (long)((num * (float)M_MULT) * sizeof(long));
> - case 'g':
> + case 'g':
> return (long)(num * (float)G_MULT);
> - case 'G':
> - return (long)((num * (float)G_MULT) * sizeof(long));
> - default:
> - return -1;
> - }
> + case 'G':
> + return (long)((num * (float)G_MULT) * sizeof(long));
> + default:
> + return -1;
> + }
> }
>
> /*
> * Force 64 bits number when compiled as 32 IRIX binary.
> * This allows for a number bigger than 2G.
> */
> -
> -long long
> -str_to_llbytes(s)
> -char *s;
> +long long str_to_llbytes(char *s)
> {
> - char mult, junk;
> - long nconv;
> - double num;
> + char mult, junk;
> + long nconv;
> + double num;
>
> - nconv = sscanf(s, "%lf%c%c", &num, &mult, &junk);
> - if (nconv == 0 || nconv == 3)
> - return -1;
> + nconv = sscanf(s, "%lf%c%c", &num, &mult, &junk);
> + if (nconv == 0 || nconv == 3)
> + return -1;
>
> - if (nconv == 1)
> - return (long long)num;
> + if (nconv == 1)
> + return (long long)num;
>
> - switch (mult) {
> - case 'b':
> + switch (mult) {
> + case 'b':
> return (long long)(num * (float)B_MULT);
> - case 'k':
> + case 'k':
> return (long long)(num * (float)K_MULT);
> - case 'K':
> + case 'K':
> return (long long)((num * (float)K_MULT) * sizeof(long long));
> - case 'm':
> + case 'm':
> return (long long)(num * (float)M_MULT);
> - case 'M':
> + case 'M':
> return (long long)((num * (float)M_MULT) * sizeof(long long));
> - case 'g':
> + case 'g':
> return (long long)(num * (float)G_MULT);
> - case 'G':
> - return (long long)((num * (float)G_MULT) * sizeof(long long));
> - default:
> - return -1;
> - }
> + case 'G':
> + return (long long)((num * (float)G_MULT) * sizeof(long long));
> + default:
> + return -1;
> + }
> }
>
> #ifdef UNIT_TEST
>
> main(int argc, char **argv)
> {
> - int ind;
> + int ind;
>
> - if (argc == 1) {
> - fprintf(stderr, "missing str_to_bytes() parameteres\n");
> - exit(1);
> - }
> + if (argc == 1) {
> + fprintf(stderr, "missing str_to_bytes() parameteres\n");
> + exit(1);
> + }
>
> - for (ind=1; ind<argc; ind++) {
> + for (ind = 1; ind < argc; ind++) {
>
> - printf("str_to_bytes(%s) returned %d\n",
> - argv[ind], str_to_bytes(argv[ind]));
> + printf("str_to_bytes(%s) returned %d\n",
> + argv[ind], str_to_bytes(argv[ind]));
>
> - printf("str_to_lbytes(%s) returned %ld\n",
> - argv[ind], str_to_lbytes(argv[ind]));
> + printf("str_to_lbytes(%s) returned %ld\n",
> + argv[ind], str_to_lbytes(argv[ind]));
>
> - printf("str_to_llbytes(%s) returned %lld\n",
> - argv[ind], str_to_llbytes(argv[ind]));
> - }
> + printf("str_to_llbytes(%s) returned %lld\n",
> + argv[ind], str_to_llbytes(argv[ind]));
> + }
> }
>
> -#endif
> \ No newline at end of file
> +#endif
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next parent reply other threads:[~2012-05-14 7:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1336655089-26941-1-git-send-email-marios.makris@gmail.com>
2012-05-14 7:15 ` Wanlong Gao [this message]
2012-05-16 14:23 ` [LTP] [PATCH 1/3] Indentation and coding style fixes on /lib/str_to_bytes.c as well as /include/str_to_bytes.h Cyril Hrubis
[not found] ` <1336655089-26941-2-git-send-email-marios.makris@gmail.com>
2012-05-14 7:16 ` [LTP] [PATCH 2/3] Renamed /lib/str_to_bytes.c and /include str_to bytes.h Wanlong Gao
[not found] ` <1336655089-26941-3-git-send-email-marios.makris@gmail.com>
2012-05-14 7:24 ` [LTP] [PATCH 3/3] Changed nconv variable from long to int in /lib/bytes_by_prefix.c Wanlong Gao
2012-05-15 11:51 ` Marioh mrs
2012-05-15 12:02 ` Wanlong Gao
2012-05-15 12:36 ` Marioh mrs
2012-05-15 12:50 ` Wanlong Gao
2012-05-15 12:58 ` Marioh mrs
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=4FB0B125.3020808@cn.fujitsu.com \
--to=gaowanlong@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=marios.makris@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox