[Mesa-dev] [PATCH 1/1] clover: Remove compat::string::c_str

Jan Vesely jan.vesely at rutgers.edu
Fri Sep 5 07:19:49 PDT 2014


On Fri, 2014-09-05 at 15:51 +0200, EdB wrote:
> On Friday, September 05, 2014 09:30:52 AM Francisco Jerez wrote:
> > Jan Vesely <jan.vesely at rutgers.edu> writes:
> > > It's unsafe as compat::string is not null terminated.
> > > Fixes garbage log on successful build.
> > > 
> > > Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> > > ---
> > > 
> > > It's obviously not needed in program::build, but I'm not sure
> > > if runtime_error solution is the best one.
> > 
> > Meh, I've just pushed the fix for c_str() I submitted to the list weeks
> > ago:
> > 
> > http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4539274b6478249d52e99fa342
> > 43daacf48be80
> > 
> > Thanks.
> 
> For reference, we discuss it on this thread:
> http://lists.freedesktop.org/archives/mesa-dev/2014-August/065114.html

thanks for pointing me to this. don't know why I missed it.
I sent my rb to the other half of the patch.

jan

> 
> 
> > 
> > >  src/gallium/state_trackers/clover/core/program.cpp | 4 ++--
> > >  src/gallium/state_trackers/clover/util/compat.cpp  | 2 +-
> > >  src/gallium/state_trackers/clover/util/compat.hpp  | 5 -----
> > >  3 files changed, 3 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/src/gallium/state_trackers/clover/core/program.cpp
> > > b/src/gallium/state_trackers/clover/core/program.cpp index
> > > 30a1f0e..3e9abec 100644
> > > --- a/src/gallium/state_trackers/clover/core/program.cpp
> > > +++ b/src/gallium/state_trackers/clover/core/program.cpp
> > > @@ -61,9 +61,9 @@ program::build(const ref_vector<device> &devs, const
> > > char *opts) {> 
> > >                                                  dev.ir_target(),
> > >                                                  build_opts(dev),
> > >                                                  log));
> > >              
> > >              _binaries.insert({ &dev, module });
> > > 
> > > -            _logs.insert({ &dev, std::string(log.c_str()) });
> > > +            _logs.insert({ &dev, std::string(log) });
> > > 
> > >           } catch (const build_error &) {
> > > 
> > > -            _logs.insert({ &dev, std::string(log.c_str()) });
> > > +            _logs.insert({ &dev, std::string(log) });
> > > 
> > >              throw;
> > >           
> > >           }
> > >        
> > >        }
> > > 
> > > diff --git a/src/gallium/state_trackers/clover/util/compat.cpp
> > > b/src/gallium/state_trackers/clover/util/compat.cpp index
> > > 80d5b3e..afba92e 100644
> > > --- a/src/gallium/state_trackers/clover/util/compat.cpp
> > > +++ b/src/gallium/state_trackers/clover/util/compat.cpp
> > > @@ -34,5 +34,5 @@ exception::what() const {
> > > 
> > >  const char *
> > >  runtime_error::what() const {
> > > 
> > > -   return _what.c_str();
> > > +   return ((std::string)_what).c_str();
> > > 
> > >  }
> > > 
> > > diff --git a/src/gallium/state_trackers/clover/util/compat.hpp
> > > b/src/gallium/state_trackers/clover/util/compat.hpp index
> > > 50e1c7d..b3668c5 100644
> > > --- a/src/gallium/state_trackers/clover/util/compat.hpp
> > > +++ b/src/gallium/state_trackers/clover/util/compat.hpp
> > > @@ -280,11 +280,6 @@ namespace clover {
> > > 
> > >           }
> > >           
> > >           const char *
> > > 
> > > -         c_str() const {
> > > -            return begin();
> > > -         }
> > > -
> > > -         const char *
> > > 
> > >           find(const string &s) const {
> > >           
> > >              for (size_t i = 0; i + s.size() < size(); ++i) {
> > >              
> > >                 if (!std::memcmp(begin() + i, s.begin(), s.size()))
> 

-- 
Jan Vesely <jan.vesely at rutgers.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140905/475bb6f0/attachment.sig>


More information about the mesa-dev mailing list