[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-stable
Subject:    expand_number(3) silently truncates numeric part of the argument
From:       "Alexandre \"Sunny\" Kovalenko" <gaijin.k () gmail ! com>
Date:       2008-06-29 20:16:25
Message-ID: 1214770585.1079.13.camel () RabbitsDen
[Download RAW message or body]

I honestly don't know whether it should or should not do it, and if it
should not, what errno should be set to. Program below gives following
output on RELENG_7 as of June 28th:

sunny:RabbitsDen>./expand_number 5368709120k 
Result is 1099511627776
sunny:RabbitsDen>./expand_number 5120G
Result is 5497558138880
sunny:RabbitsDen>

One of the more interesting manifestations in the userland is that

gjournal label -s 5368709120 -f /dev/da0s1a

quietly gives you 1G of the journal in the resulting file system.

Cut here>-----------------------------------------------------------
#include <ctype.h>
#include <sys/types.h>
#include <inttypes.h>
#include <errno.h>
#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  if(argc != 2)
  {
    fprintf(stderr, "Usage: %s <number>\n", argv[0]);
    exit(1);
  }

  errno = 0;
  intmax_t result;
  if(expand_number(argv[1], &result) || errno)
  {
    perror("Expand number");
    exit(1);
  }

  printf("Result is %jd\n", result);
  exit(0);
}
Cut here>-----------------------------------------------------------

-- 
Alexandre "Sunny" Kovalenko (Олександр Коваленко)

_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic