Re: [U-Boot] [PATCH v4] palmtreo680: add utility that writes u-boot to flash

2013-04-18 Thread Marek Vasut
Dear Mike Dunn,

[...]

 + if (argc != 3) {
 + printf(usage: %s image file mtd dev node\n, argv[0]);

btw is this /dev/mtdX or /dev/mtdblockX ?

 + return -1;

errno.h didn't work? Like ... return -EINVAL or such ?

[...]

 + blockbuf = calloc(RELIABLE_BLOCKSIZE, 1);

calloc() semantics are misunderstood by so many :-(

[...]

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4] palmtreo680: add utility that writes u-boot to flash

2013-04-18 Thread Mike Dunn
On 04/18/2013 06:54 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 [...]
 
 +if (argc != 3) {
 +printf(usage: %s image file mtd dev node\n, argv[0]);
 
 btw is this /dev/mtdX or /dev/mtdblockX ?


/dev/mtdx  You must have defined a partition that starts at the offset at which
you are placing the u-boot image, and of course is big enough to hold the image.


 
 +return -1;
 
 errno.h didn't work? Like ... return -EINVAL or such ?


'return -EINVAL' works, sure.  Are you suggesting that the utility should return
an intelligent error code at all failure exit points?  Like if the call to
calloc() fails, it should return -ENOMEM?  I could do that if you prefer.  I
didn't worry about it because I always print the reason for the failure to
stderr, usually by way of perror().  Sorry, I guess I didn't understand your
initial suggestion.


 
 [...]
 
 +blockbuf = calloc(RELIABLE_BLOCKSIZE, 1);
 
 calloc() semantics are misunderstood by so many :-(


calloc(RELIABLE_BLOCKSIZE, sizeof(char)) ?


Thanks,
Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4] palmtreo680: add utility that writes u-boot to flash

2013-04-18 Thread Marek Vasut
Dear Mike Dunn,

 On 04/18/2013 06:54 AM, Marek Vasut wrote:
  Dear Mike Dunn,
  
  [...]
  
  +  if (argc != 3) {
  +  printf(usage: %s image file mtd dev node\n, argv[0]);
  
  btw is this /dev/mtdX or /dev/mtdblockX ?
 
 /dev/mtdx  You must have defined a partition that starts at the offset at
 which you are placing the u-boot image, and of course is big enough to
 hold the image.
 
  +  return -1;
  
  errno.h didn't work? Like ... return -EINVAL or such ?
 
 'return -EINVAL' works, sure.  Are you suggesting that the utility should
 return an intelligent error code at all failure exit points?  Like if the
 call to calloc() fails, it should return -ENOMEM?  I could do that if you
 prefer.  I didn't worry about it because I always print the reason for the
 failure to stderr, usually by way of perror().  Sorry, I guess I didn't
 understand your initial suggestion.

I think it's more correct to return proper error code, maybe try getting 
opinion from the others.

  [...]
  
  +  blockbuf = calloc(RELIABLE_BLOCKSIZE, 1);
  
  calloc() semantics are misunderstood by so many :-(
 
 calloc(RELIABLE_BLOCKSIZE, sizeof(char)) ?

from malloc(3):

   void *calloc(size_t nmemb, size_t size);

[...]

The  calloc() function allocates memory for an array of nmemb elements of size
bytes each and returns a pointer to the allocated memory.  The memory is set to
zero.  If nmemb or size is 0, then calloc() returns either NULL, or  a  unique
pointer value that can later be successfully passed to free().

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot