when we get an NDR error in the logs, it is useful to know where it happened
authorAndrew Tridgell <tridge@samba.org>
Wed, 12 Aug 2009 05:33:37 +0000 (15:33 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 12 Aug 2009 05:33:37 +0000 (15:33 +1000)
librpc/ndr/libndr.h
pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

index 7109b73d2a962f395e3dbf6a61de2d48b6802378..53bed011e7ccea467a36a891a6012fec5762afdc 100644 (file)
@@ -215,7 +215,7 @@ enum ndr_compression_alg {
 
 #define NDR_PULL_NEED_BYTES(ndr, n) do { \
        if ((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size) { \
 
 #define NDR_PULL_NEED_BYTES(ndr, n) do { \
        if ((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size) { \
-               return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull bytes %u", (unsigned)n); \
+               return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull bytes %u (%s)", (unsigned)n, __location__); \
        } \
 } while(0)
 
        } \
 } while(0)
 
index 3e724c986da89fc47cd121c7519e3e6c60cde80e..cc8085a54fdb577290c7c30cc4a3e49e35803bcb 100644 (file)
@@ -1669,7 +1669,7 @@ sub ParseUnionPushPrimitives($$$$)
        }
        if (! $have_default) {
                $self->pidl("default:");
        }
        if (! $have_default) {
                $self->pidl("default:");
-               $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+               $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u at \%s\", level, __location__);");
        }
        $self->deindent;
        $self->pidl("}");
        }
        $self->deindent;
        $self->pidl("}");
@@ -1705,7 +1705,7 @@ sub ParseUnionPushDeferred($$$$)
        }
        if (! $have_default) {
                $self->pidl("default:");
        }
        if (! $have_default) {
                $self->pidl("default:");
-               $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+               $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u at \%s\", level, __location__);");
        }
        $self->deindent;
        $self->pidl("}");
        }
        $self->deindent;
        $self->pidl("}");
@@ -1784,7 +1784,7 @@ sub ParseUnionPullPrimitives($$$$$)
        if (defined($switch_type)) {
                $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));");
                $self->pidl("if (_level != level) {"); 
        if (defined($switch_type)) {
                $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));");
                $self->pidl("if (_level != level) {"); 
-               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname\", _level);");
+               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname at \%s\", _level, __location__);");
                $self->pidl("}");
        }
 
                $self->pidl("}");
        }
 
@@ -1814,7 +1814,7 @@ sub ParseUnionPullPrimitives($$$$$)
        }
        if (! $have_default) {
                $self->pidl("default:");
        }
        if (! $have_default) {
                $self->pidl("default:");
-               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u at \%s\", level, __location__);");
        }
        $self->deindent;
        $self->pidl("}");
        }
        $self->deindent;
        $self->pidl("}");
@@ -1848,7 +1848,7 @@ sub ParseUnionPullDeferred($$$$)
        }
        if (! $have_default) {
                $self->pidl("default:");
        }
        if (! $have_default) {
                $self->pidl("default:");
-               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u at \%s\", level, __location__);");
        }
        $self->deindent;
        $self->pidl("}");
        }
        $self->deindent;
        $self->pidl("}");