Cosimo Streppone via RT wrote:
Sun Jul 19 10:43:11 2009: Request 48006 was acted upon.
Transaction: Ticket created by COSIMO
       Queue: Win32-API
     Subject: Warnings from Win32::API::Struct
   Broken in: (no value)
    Severity: Normal
       Owner: COSIMO
  Requestors: kill...@multiplay.co.uk
      Status: new
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=48006 >


loads of warnings when using the module:

  return $self->{align} unless $self->{align} eq 'auto';
Should it be:

  return $self->{align} unless ! defined $self->{align} || $self->
{align} eq 'auto';

But not 100% sure?
In addition there are a number of debug lines which also cause loads
of warnings:
Struct.pm:221 DEBUG "(PM)Struct::getPack: $self->{__typedef__}
(buffer) = pack($packing, @items)\n";
Struct.pm:229 DEBUG "(PM)Struct::Pack: $self->{__typedef__}(buffer) = pack($packing, @$items)\n";

I think there are some bugs in there too.  Does sizeof work properly
in the current version ?  There might be alignment issues too.
I'm using 0.50.

Here's a test case that should show the sizeof problem:

use strict;
use warnings;
use Win32::API::Struct;

typedef Win32::API::Struct PROCESSENTRY32 => qw(
    DWORD dwSize;
    DWORD cntUsage;
    DWORD th32ProcessID;
    DWORD th32DefaultHeapID;
    DWORD th32ModuleID;
    DWORD cntThreads;
    DWORD th32ParentProcessID;
    LONG  pcPriClassBase;
    DWORD dwFlags;
    char szExeFile[260];
);      # 9*4=36+260=296
my $pe32 = new Win32::API::Struct ('PROCESSENTRY32');
my $size = $pe32->sizeof;
print "size=$size should be 296\n";

__END__

This produces:
size=40 should be 296

I changed my version of Struct.pm to alleviate the symptom, but
not sure if it's the correct change (my changes on the right >):

143,147c144,148
<       if(defined $align and $align > 0) {
<       return scalar(@{ $self->{typedef} }) * $align;
<     } else {
<       return $size;
<     }
---
> #     if(defined $align and $align > 0) {     $Bill - comment out this align 
test
> #             return scalar(@{ $self->{typedef} }) * $align;  $Bill
> #     } else {        $Bill
> #             return $size;   $Bill
> #     }       $Bill
189c190
<         ($name, $type, my $orig) = @$member;  # $Bill - just a strict issue
---
>       ($name, $type, $orig) = @$member;
246c247
<         ($name, $type, $orig) = @$member;
---
>         ($name, $type, my $orig) = @$member;  # $Bill - just a strict issue

There may be other issues.

Reply via email to