You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "Mikhail Koviazin (Jira)" <ji...@apache.org> on 2024/02/21 20:31:00 UTC

[jira] [Assigned] (AVRO-3945) Fix issues reported by cppcheck

     [ https://issues.apache.org/jira/browse/AVRO-3945?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Koviazin reassigned AVRO-3945:
--------------------------------------


> Fix issues reported by cppcheck
> -------------------------------
>
>                 Key: AVRO-3945
>                 URL: https://issues.apache.org/jira/browse/AVRO-3945
>             Project: Apache Avro
>          Issue Type: Task
>          Components: c++
>            Reporter: Mikhail Koviazin
>            Assignee: Mikhail Koviazin
>            Priority: Minor
>
> This issue can be split into different stages.
>  
> 1. Add missing override:
>  
> {code:java}
> impl/FileStream.cc:52:5: style: Struct 'FileBufferCopyIn' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     FileBufferCopyIn(const char *filename) : h_(::CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
>     ^
> impl/FileStream.cc:235:5: style: Struct 'FileBufferCopyOut' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     FileBufferCopyOut(const char *filename) : h_(::CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
>     ^
> impl/FileStream.cc:62:10: style: The function 'seek' overrides a function in a base class but is not marked with a 'override' specifier. [missingOverride]
>     void seek(size_t len) {
>          ^
> impl/FileStream.cc:45:18: note: Virtual function in base class
>     virtual void seek(size_t len) = 0;
>                  ^
> impl/FileStream.cc:62:10: note: Function in derived class
>     void seek(size_t len) {
>          ^
> impl/FileStream.cc:68:10: style: The function 'read' overrides a function in a base class but is not marked with a 'override' specifier. [missingOverride]
>     bool read(uint8_t *b, size_t toRead, size_t &actual) {
>          ^
> impl/FileStream.cc:46:18: note: Virtual function in base class
>     virtual bool read(uint8_t *b, size_t toRead, size_t &actual) = 0;
>                  ^
> impl/FileStream.cc:68:10: note: Function in derived class
>     bool read(uint8_t *b, size_t toRead, size_t &actual) {
>          ^
> impl/FileStream.cc:245:10: style: The function 'write' overrides a function in a base class but is not marked with a 'override' specifier. [missingOverride]
>     void write(const uint8_t *b, size_t len) {
>          ^
> impl/FileStream.cc:229:18: note: Virtual function in base class
>     virtual void write(const uint8_t *b, size_t len) = 0;
>                  ^
> impl/FileStream.cc:245:10: note: Function in derived class
>     void write(const uint8_t *b, size_t len) {
>  {code}
>  
> 2. Constructors with 1 argument not marked as "explicit"
> {code:java}
> impl/json/JsonDom.hh:79:5: style: Class 'Entity' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     Entity(Bool v, size_t line = 0) : type_(EntityType::Bool), value_(v), line_(line) {}
>     ^
> impl/json/JsonDom.hh:82:5: style: Class 'Entity' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     Entity(Long v, size_t line = 0) : type_(EntityType::Long), value_(v), line_(line) {}
>     ^
> impl/json/JsonDom.hh:85:5: style: Class 'Entity' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     Entity(Double v, size_t line = 0) : type_(EntityType::Double), value_(v), line_(line) {}
>     ^
> impl/json/JsonDom.hh:88:5: style: Class 'Entity' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     Entity(const std::shared_ptr<String> &v, size_t line = 0) : type_(EntityType::String), value_(v), line_(line) {}
>     ^
> impl/json/JsonDom.hh:91:5: style: Class 'Entity' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     Entity(const std::shared_ptr<Array> &v, size_t line = 0) : type_(EntityType::Arr), value_(v), line_(line) {}
>     ^
> impl/json/JsonDom.hh:94:5: style: Class 'Entity' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     Entity(const std::shared_ptr<Object> &v, size_t line = 0) : type_(EntityType::Obj), value_(v), line_(line) {}
>     ^
> impl/FileStream.cc:52:5: style: Struct 'FileBufferCopyIn' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     FileBufferCopyIn(const char *filename) : h_(::CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
>     ^
> impl/FileStream.cc:235:5: style: Struct 'FileBufferCopyOut' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
>     FileBufferCopyOut(const char *filename) : h_(::CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
>     ^
>  {code}
>  
> 3. Missing bound check (!) (This can cause actual logic errors)
> {code:java}
> impl/json/JsonIO.cc:319:66: warning: Missing bounds check for extra iterator increment in loop. [StlMissingComparison]
>     for (string::const_iterator it = s.cbegin(); it != s.cend(); ++it) {
>                                                                  ^
> impl/json/JsonIO.cc:350:37: note: Missing bounds check for extra iterator increment in loop.
>                         char c = *++it;
>                                     ^
> impl/json/JsonIO.cc:319:66: note: Missing bounds check for extra iterator increment in loop.
>     for (string::const_iterator it = s.cbegin(); it != s.cend(); ++it) {
>   {code}
> 4. Smaller changes that are mostly stylish
>  
> I can create PRs for each stage.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)