Coder Social home page Coder Social logo

Comments (8)

patacongo avatar patacongo commented on August 29, 2024

The */ is normally not on a separate line on right hand comments. Does this eliminte the problem?

struct a_struct_s
{
   uint8_t f1; /* Long line in a single comment, OK. */
   uint8_t f2; /* Long line in a block comment,
                * nxstyle complains.  */
};

from nuttx.

Ouss4 avatar Ouss4 commented on August 29, 2024

Tried this as well. I got the same complaints.

from nuttx.

patacongo avatar patacongo commented on August 29, 2024

Can you please generate a test case? I created this file, junk.c:

/****************************************************************************
 * junk.c
 ****************************************************************************/

/****************************************************************************
 * Included Files
****************************************************************************/

#include <stdint.h>

/****************************************************************************
 * Private Types
 ****************************************************************************/

struct a_struct_s
{
  uint8_t f1; /* Long line in a single comment, OK. */
  uint8_t f2; /* Long line in a block comment,
               * nxstyle complains.
               */
};

/****************************************************************************
 * Public Functions
 ****************************************************************************/

But nxstyle is completely happy with that... no complaints at all. Nor have I ever seen a problem in the past. So I am thinking that this is context specific problem. So I think to resolve it, you will need to provide a full test file that shows the failure in context.

Is there an existing file in the repository?

from nuttx.

patacongo avatar patacongo commented on August 29, 2024

Looking back through the PR chekcs for I think I see the issue you are referring to: https://github.com/apache/incubator-nuttx/runs/562410318?check_suite_focus=true

The file is arch/arm/src/imxrt/imxrt_enc.c and these errors were reported:

arch/arm/src/imxrt/imxrt_enc.c:266:78: error: Long line found
arch/arm/src/imxrt/imxrt_enc.c:269:78: error: Long line found
arch/arm/src/imxrt/imxrt_enc.c:272:82: error: Long line found
arch/arm/src/imxrt/imxrt_enc.c:273:80: error: Long line found
arch/arm/src/imxrt/imxrt_enc.c:296:78: error: Long line found

Looking at those, I see that these are not related to the right hand comments at all. These are simply saying that the lines are too long. I verfied each that this is the case. They ARE too long.

 261 struct imxrt_qeconfig_s
 262 {
 263   uint32_t  base;           /* Register base address */
 264   uint32_t  init_val;       /* Value to initialize position counters to */
 265   uint32_t  modulus;        /* Modulus to use when modulo counting is enabled */
 266   uint16_t  in_filt_per;    /* Period for input filter sampling in # of periph
 267                              * clock cycles
 268                              */
 269   uint16_t  in_filt_cnt;    /* # of consecutive input filter samples that must
 270                              * agree
 271                              */
 272   uint16_t  init_flags;     /* Flags to control which signals and edge transitions
 273                              * will reinitialize the position counter. Bits 4-0:
 274                              * [MOD, REV, XNE, XIP, HNE, HIP]
 275                              */
 276
 277 #ifdef CONFIG_DEBUG_SENSORS
 278   bool      tst_dir_adv;    /* Whether to generate down/up test signals */
 279   uint8_t   tst_period;     /* Period of PHASE pulses in # of periph clock cycles */
 280 #endif
 281 };

And

 285 struct imxrt_enc_lowerhalf_s
 286 {
 287   /* The first field of this state structure must be a pointer to the lower-
 288    * half callback structure:
 289    */
 290
 291   FAR const struct qe_ops_s *ops;             /* Lower half callback structure */
 292
 293   /* IMXRT driver-specific fields: */
 294
 295   FAR const struct imxrt_qeconfig_s *config;  /* static configuration */
 296   sem_t sem_excl;                             /* Mutual exclusion semaphore to
 297                                                * ensure atomic 32-bit reads.
 298                                                */
 299 };

When I run the current nxstyle against the current imxrt_enc.c I get:

$ tools/nxstyle.exe arch/arm/src/imxrt/imxrt_enc.c
arch/arm/src/imxrt/imxrt_enc.c:1037:81: error: Long line found
arch/arm/src/imxrt/imxrt_enc.c:1043:84: error: Long line found

To things to note:

  1. The errors at liness 266-296 no longer appear. That is a regression. They truly are too long.
  2. New long lines are reported at 1037 and 1043. These are correct and appear not due to a recent fix to nxstyle.

So I am thinking that this Issue should be closed. Please give your feeback before I close it.

from nuttx.

Ouss4 avatar Ouss4 commented on August 29, 2024

Yes, the lines are too long. But nxstyle ignores long lines when it's a comment at the right of struct field for instance.
This is used throughout the code base to comment struct fields, so the exception was added to nxstyle not too long ago.
The issue is, single line comments are ignored and no complaints is raised, however if it's a block (and long) comment, now nxstyle complains about the length.

from nuttx.

patacongo avatar patacongo commented on August 29, 2024

Yes, the lines are too long. But nxstyle ignores long lines when it's a comment at the right of struct field for instance.

I does not, but it did not use too. That is a different error recently introduced into nxstyle when the right hand comment alignment logic was added. We lost the length check then.

This is used throughout the code base to comment struct fields, so the exception was added to nxstyle not too long ago.

It wasn't added intentionally. It was an error that was introduced recently. Now it turns out, I think it is a good behavior at least for now because there are two many long, right-hand comments, espectially int arch/ header definition header files.

The issue is, single line comments are ignored and no complaints is raised, however if it's a block (and long) comment, now nxstyle complains about the length.

Let me modify my junk.c to make the lines too long and try again.

from nuttx.

patacongo avatar patacongo commented on August 29, 2024

Nope, no long line is reported. Here is the modified junk.c file:

/****************************************************************************
 * junk.c
 ****************************************************************************/

/****************************************************************************
 * Included Files
 ****************************************************************************/

#include <stdint.h>

/****************************************************************************
 * Private Types
 ****************************************************************************/

struct a_struct_s
{
  uint8_t f1; /* This is a very long line in a single right-hand comment, No error is reported OK. */
  uint8_t f2; /* This is a a very long line in a block comment.  In this case nxstyle complains
               * and an error is reported.
               */
};

/****************************************************************************
 * Public Functions
 ****************************************************************************/

But nxstyle does not complain about the long lines at all. I am not sure that that is good. It is good for now, but there is no exception in the coding standard for long right hand comments. They are also a violation of the coding standard, we just do not want to deal with them now:

The long right hand comments in arch/arm/src/imxrt/imxrt_enc.c no longer generate errors either. So I conclude that this issue as reported no longer exists. I believe that there are still issues wtih long lines: They should be reported. But given the context of this issue, it can be closed now.

from nuttx.

Ouss4 avatar Ouss4 commented on August 29, 2024

Let me modify my junk.c to make the lines too long and try again.

I did so too. And I confirm that nxstyle is working as it should be!

Looking back through the PR chekcs for I think I see the issue you are referring to: https://github.com/apache/incubator-nuttx/runs/562410318?check_suite_focus=true

We can also see that some of the errors generated here no longer appear. An example is line 272.

from nuttx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.