From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sage Weil Subject: Re: New Defects reported by Coverity Scan for ceph Date: Sat, 27 Dec 2014 22:03:33 -0800 (PST) Message-ID: References: <549ebe8058e0c_64e685d3388867e@scan.coverity.com.mail> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: Received: from cobra.newdream.net ([66.33.216.30]:60627 "EHLO cobra.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751045AbaL1GDd (ORCPT ); Sun, 28 Dec 2014 01:03:33 -0500 In-Reply-To: <549ebe8058e0c_64e685d3388867e@scan.coverity.com.mail> Sender: ceph-devel-owner@vger.kernel.org List-ID: To: haomaiwang@gmail.com Cc: ceph-devel@vger.kernel.org Haomai, may want to double-check the pointer arithmetic here (and/or add a cast to make coverity less suspicious). sage On Sat, 27 Dec 2014, scan-admin@coverity.com wrote: > > Hi, > > Please find the latest report on new defect(s) introduced to ceph found with Coverity Scan. > > 1 new defect(s) introduced to ceph found with Coverity Scan. > 1 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan. > > New defect(s) Reported-by: Coverity Scan > Showing 1 of 1 defect(s) > > > ** CID 1260497: Extra sizeof expression (SIZEOF_MISMATCH) > /msg/async/Event.cc: 123 in EventCenter::create_file_event(int, int, std::tr1::shared_ptr)() > > > ________________________________________________________________________________________________________ > *** CID 1260497: Extra sizeof expression (SIZEOF_MISMATCH) > /msg/async/Event.cc: 123 in EventCenter::create_file_event(int, int, std::tr1::shared_ptr)() > 117 } > 118 FileEvent *new_events = static_cast(realloc(file_events, sizeof(FileEvent)*new_size)); > 119 if (!new_events) { > 120 lderr(cct) << __func__ << " failed to realloc file_events" << cpp_strerror(errno) << dendl; > 121 return -errno; > 122 } > >>> CID 1260497: Extra sizeof expression (SIZEOF_MISMATCH) > >>> Adding "40UL /* sizeof (EventCenter::FileEvent) */ * this->nevent" to pointer "this->file_events" of type "EventCenter::FileEvent *" is suspicious because adding an integral value to this pointer automatically scales that value by the size, 40 bytes, of the pointed-to type, "EventCenter::FileEvent". Most likely, the multiplication by "sizeof (EventCenter::FileEvent)" in this expression is extraneous and should be eliminated. > 123 memset(file_events+sizeof(FileEvent)*nevent, 0, sizeof(FileEvent)*(new_size-nevent)); > 124 file_events = new_events; > 125 nevent = new_size; > 126 } > 127 > 128 EventCenter::FileEvent *event = _get_file_event(fd); > > > ________________________________________________________________________________________________________ > To view the defects in Coverity Scan visit, http://scan.coverity.com/projects/25?tab=overview > > To manage Coverity Scan email notifications for "ceph-devel@vger.kernel.org", click http://scan.coverity.com/subscriptions/edit?email=ceph-devel%40vger.kernel.org&token=018084d671e3cc89d00dd2ccb7eb849c . > > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > >