Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Ruby warnings #124

Merged
merged 1 commit into from Jun 5, 2019
Merged

Reduce Ruby warnings #124

merged 1 commit into from Jun 5, 2019

Conversation

pocke
Copy link
Contributor

@pocke pocke commented May 24, 2019

Problem

sassc-ruby displays warnings on load the gem if -w options is passed to ruby interpreter.

$ ruby -w -rsassc -e ''
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _context_get_included_files
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _context_get_included_files
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_length
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_length
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_value
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_value

This pull request suppresses the warnings.

Note

sassc-ruby has other warnings in test code, but this pull request does not suppress the warnings. Because they does not affect users.
If you'd like to see the warning, you can execute rake test with RUBYOPT=-w environment variable.

Problem
===

sassc-ruby displays warnings on load the gem if `-w` options is passed to ruby interpreter.

```console
$ ruby -w -rsassc -e ''
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _context_get_included_files
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old _context_get_included_files
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_length
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_length
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_value
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275:
warning: method redefined; discarding old list_get_value
```

This pull request suppresses the warnings.

Note
===

sassc-ruby has other warnings in test code, but this pull request does not suppress the warnings. Because they does not affect users.
If you'd like to see the warning, you can execute `rake test` with `RUBYOPT=-w` environment variable.
@@ -42,7 +42,7 @@ module Native

# Remove the redundant "sass_" from the beginning of every method name
def self.attach_function(*args)
super if args.size != 3
return super if args.size != 3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If args.size != 3, the super method is called twice. It is meaningless, so it should return after super is called.

This change suppresses the following warnings.

/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _context_get_included_files
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _context_get_included_files

# ADDAPI size_t ADDCALL sass_list_get_length(const union Sass_Value* v)
# ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i);
attach_function :sass_list_get_length, [:sass_value_ptr], :size_t
attach_function :sass_list_get_value, [:sass_value_ptr, :size_t], :sass_value_ptr
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are the same definitions here.

# ADDAPI size_t ADDCALL sass_list_get_length (const union Sass_Value* v);
attach_function :sass_list_get_length, [:sass_value_ptr], :size_t

# ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i);
attach_function :sass_list_get_value, [:sass_value_ptr, :size_t], :sass_value_ptr

@bolandrm bolandrm merged commit 3a26ea4 into sass:master Jun 5, 2019
@pocke pocke deleted the reduce-warnings branch June 6, 2019 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants