<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 31, 2018 at 8:54 AM, Eric Engestrom <span dir="ltr"><<a href="mailto:eric.engestrom@intel.com" target="_blank">eric.engestrom@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tuesday, 2018-05-29 09:55:05 -0700, Jason Ekstrand wrote:<br>
> Does this fix something?  If I understand correctly, the first blob_write<br>
> to fail will set out_of_memory and all subsequent blob_writes will fail.<br>
<br>
</span>You're right actually, I didn't look deep enough.<br>
<br>
> Does this fix something?<br>
<br>
My clang complained about ok being overwritten without being read, and<br>
my shallow investigation didn't catch the out_of_memory flag in<br>
grow_to_fit().<br>
<br>
I guess we could drop `ok` and all its assignments, and simply return<br>
the last blob_write_bytes() call, or I could just drop it as it's not<br>
really important as it turns out there isn't any actual bug :]<br><div class="HOEnZb"><div class="h5"></div></div></blockquote><div><br></div><div>Sounds like a plan. :)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> <br>
> On Tue, May 29, 2018 at 9:12 AM, Eric Engestrom <<a href="mailto:eric.engestrom@intel.com">eric.engestrom@intel.com</a>><br>
> wrote:<br>
> <br>
> > Signed-off-by: Eric Engestrom <<a href="mailto:eric.engestrom@intel.com">eric.engestrom@intel.com</a>><br>
> > ---<br>
> >  src/intel/vulkan/anv_pipeline_<wbr>cache.c | 38 +++++++++++++--------------<br>
> >  1 file changed, 19 insertions(+), 19 deletions(-)<br>
> ><br>
> > diff --git a/src/intel/vulkan/anv_<wbr>pipeline_cache.c b/src/intel/vulkan/anv_<br>
> > pipeline_cache.c<br>
> > index 82551e9f81f293ecadbe..<wbr>6c0edaf1ec1b773802e1 100644<br>
> > --- a/src/intel/vulkan/anv_<wbr>pipeline_cache.c<br>
> > +++ b/src/intel/vulkan/anv_<wbr>pipeline_cache.c<br>
> > @@ -96,29 +96,29 @@ static bool<br>
> >  anv_shader_bin_write_to_blob(<wbr>const struct anv_shader_bin *shader,<br>
> >                               struct blob *blob)<br>
> >  {<br>
> > -   bool ok;<br>
> > +   bool ok = true;<br>
> ><br>
> > -   ok = blob_write_uint32(blob, shader->key->size);<br>
> > -   ok = blob_write_bytes(blob, shader->key->data, shader->key->size);<br>
> > +   ok &= blob_write_uint32(blob, shader->key->size);<br>
> > +   ok &= blob_write_bytes(blob, shader->key->data, shader->key->size);<br>
> ><br>
> > -   ok = blob_write_uint32(blob, shader->kernel_size);<br>
> > -   ok = blob_write_bytes(blob, shader->kernel.map, shader->kernel_size);<br>
> > +   ok &= blob_write_uint32(blob, shader->kernel_size);<br>
> > +   ok &= blob_write_bytes(blob, shader->kernel.map, shader->kernel_size);<br>
> ><br>
> > -   ok = blob_write_uint32(blob, shader->prog_data_size);<br>
> > -   ok = blob_write_bytes(blob, shader->prog_data, shader->prog_data_size);<br>
> > -   ok = blob_write_bytes(blob, shader->prog_data->param,<br>
> > -                               shader->prog_data->nr_params *<br>
> > -                               sizeof(*shader->prog_data-><wbr>param));<br>
> > +   ok &= blob_write_uint32(blob, shader->prog_data_size);<br>
> > +   ok &= blob_write_bytes(blob, shader->prog_data,<br>
> > shader->prog_data_size);<br>
> > +   ok &= blob_write_bytes(blob, shader->prog_data->param,<br>
> > +                                shader->prog_data->nr_params *<br>
> > +                                sizeof(*shader->prog_data-><wbr>param));<br>
> ><br>
> > -   ok = blob_write_uint32(blob, shader->bind_map.surface_<wbr>count);<br>
> > -   ok = blob_write_uint32(blob, shader->bind_map.sampler_<wbr>count);<br>
> > -   ok = blob_write_uint32(blob, shader->bind_map.image_count);<br>
> > -   ok = blob_write_bytes(blob, shader->bind_map.surface_to_<wbr>descriptor,<br>
> > -                               shader->bind_map.surface_count *<br>
> > -                               sizeof(*shader->bind_map.<br>
> > surface_to_descriptor));<br>
> > -   ok = blob_write_bytes(blob, shader->bind_map.sampler_to_<wbr>descriptor,<br>
> > -                               shader->bind_map.sampler_count *<br>
> > -                               sizeof(*shader->bind_map.<br>
> > sampler_to_descriptor));<br>
> > +   ok &= blob_write_uint32(blob, shader->bind_map.surface_<wbr>count);<br>
> > +   ok &= blob_write_uint32(blob, shader->bind_map.sampler_<wbr>count);<br>
> > +   ok &= blob_write_uint32(blob, shader->bind_map.image_count);<br>
> > +   ok &= blob_write_bytes(blob, shader->bind_map.surface_to_<wbr>descriptor,<br>
> > +                                shader->bind_map.surface_count *<br>
> > +                                sizeof(*shader->bind_map.<br>
> > surface_to_descriptor));<br>
> > +   ok &= blob_write_bytes(blob, shader->bind_map.sampler_to_<wbr>descriptor,<br>
> > +                                shader->bind_map.sampler_count *<br>
> > +                                sizeof(*shader->bind_map.<br>
> > sampler_to_descriptor));<br>
> ><br>
> >     return ok;<br>
> >  }<br>
> > --<br>
> > Cheers,<br>
> >   Eric<br>
> ><br>
> ><br>
</div></div></blockquote></div><br></div></div>